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.



2061
2062
2063
2064
2065
2066
# File 'lib/mockserver/models.rb', line 2061

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.



2059
2060
2061
# File 'lib/mockserver/models.rb', line 2059

def match_pattern
  @match_pattern
end

#scenario_nameObject

Returns the value of attribute scenario_name.



2059
2060
2061
# File 'lib/mockserver/models.rb', line 2059

def scenario_name
  @scenario_name
end

#target_stateObject

Returns the value of attribute target_state.



2059
2060
2061
# File 'lib/mockserver/models.rb', line 2059

def target_state
  @target_state
end

#triggerObject

Returns the value of attribute trigger.



2059
2060
2061
# File 'lib/mockserver/models.rb', line 2059

def trigger
  @trigger
end

Class Method Details

.from_hash(data) ⇒ Object



2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
# File 'lib/mockserver/models.rb', line 2077

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



2068
2069
2070
2071
2072
2073
2074
2075
# File 'lib/mockserver/models.rb', line 2068

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