Class: HttpStub::Configurator::State

Inherits:
Object
  • Object
show all
Defined in:
lib/http_stub/configurator/state.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeState

Returns a new instance of State.


12
13
14
15
16
# File 'lib/http_stub/configurator/state.rb', line 12

def initialize
  @scenario_hashes           = []
  @stub_hashes               = []
  @cross_origin_support_flag = false
end

Instance Attribute Details

#portObject

Returns the value of attribute port


6
7
8
# File 'lib/http_stub/configurator/state.rb', line 6

def port
  @port
end

#scenario_hashesObject (readonly)

Returns the value of attribute scenario_hashes


10
11
12
# File 'lib/http_stub/configurator/state.rb', line 10

def scenario_hashes
  @scenario_hashes
end

#session_identifier=(value) ⇒ Object (writeonly)

Sets the attribute session_identifier

Parameters:

  • value

    the value to set the attribute session_identifier to.


8
9
10
# File 'lib/http_stub/configurator/state.rb', line 8

def session_identifier=(value)
  @session_identifier = value
end

#stub_hashesObject (readonly)

Returns the value of attribute stub_hashes


10
11
12
# File 'lib/http_stub/configurator/state.rb', line 10

def stub_hashes
  @stub_hashes
end

Instance Method Details

#add_scenario(scenario) ⇒ Object


26
27
28
# File 'lib/http_stub/configurator/state.rb', line 26

def add_scenario(scenario)
  @scenario_hashes << scenario.to_hash
end

#add_stub(stub) ⇒ Object


30
31
32
# File 'lib/http_stub/configurator/state.rb', line 30

def add_stub(stub)
  @stub_hashes << stub.to_hash
end

#application_settingsObject


34
35
36
# File 'lib/http_stub/configurator/state.rb', line 34

def application_settings
  { port: @port, session_identifier: @session_identifier, cross_origin_support: @cross_origin_support_flag }
end

#enable(feature) ⇒ Object


22
23
24
# File 'lib/http_stub/configurator/state.rb', line 22

def enable(feature)
  @cross_origin_support_flag = true if feature == :cross_origin_support
end

#external_base_uriObject


18
19
20
# File 'lib/http_stub/configurator/state.rb', line 18

def external_base_uri
  ENV["STUB_EXTERNAL_BASE_URI"] || "http://localhost:#{@port}"
end