Class: MockServer::CrossProtocolScenario

Inherits:
Object
  • Object
show all
Defined in:
lib/mockserver/models.rb

Overview

Describes a cross-protocol scenario correlation: when a protocol event matching trigger (and optionally match_pattern) is observed, the named scenario scenario_name is advanced to target_state.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(trigger: nil, match_pattern: nil, scenario_name: nil, target_state: nil) ⇒ CrossProtocolScenario

Returns a new instance of CrossProtocolScenario.



1771
1772
1773
1774
1775
1776
# File 'lib/mockserver/models.rb', line 1771

def initialize(trigger: nil, match_pattern: nil, scenario_name: nil, target_state: nil)
  @trigger = trigger
  @match_pattern = match_pattern
  @scenario_name = scenario_name
  @target_state = target_state
end

Instance Attribute Details

#match_patternObject

Returns the value of attribute match_pattern.



1769
1770
1771
# File 'lib/mockserver/models.rb', line 1769

def match_pattern
  @match_pattern
end

#scenario_nameObject

Returns the value of attribute scenario_name.



1769
1770
1771
# File 'lib/mockserver/models.rb', line 1769

def scenario_name
  @scenario_name
end

#target_stateObject

Returns the value of attribute target_state.



1769
1770
1771
# File 'lib/mockserver/models.rb', line 1769

def target_state
  @target_state
end

#triggerObject

Returns the value of attribute trigger.



1769
1770
1771
# File 'lib/mockserver/models.rb', line 1769

def trigger
  @trigger
end

Class Method Details

.from_hash(data) ⇒ Object



1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
# File 'lib/mockserver/models.rb', line 1787

def self.from_hash(data)
  return nil if data.nil?

  new(
    trigger:       data['trigger'],
    match_pattern: data['matchPattern'],
    scenario_name: data['scenarioName'],
    target_state:  data['targetState']
  )
end

Instance Method Details

#to_hObject



1778
1779
1780
1781
1782
1783
1784
1785
# File 'lib/mockserver/models.rb', line 1778

def to_h
  MockServer.strip_none({
    'trigger'      => @trigger,
    'matchPattern' => @match_pattern,
    'scenarioName' => @scenario_name,
    'targetState'  => @target_state
  })
end