Class: HttpStub::Server::Memory::InitialState
- Inherits:
-
Object
- Object
- HttpStub::Server::Memory::InitialState
- Defined in:
- lib/http_stub/server/memory/initial_state.rb
Instance Method Summary collapse
-
#initialize(configurator_state) ⇒ InitialState
constructor
A new instance of InitialState.
- #load_scenarios ⇒ Object
- #load_stubs(scenario_registry) ⇒ Object
Constructor Details
#initialize(configurator_state) ⇒ InitialState
Returns a new instance of InitialState.
7 8 9 |
# File 'lib/http_stub/server/memory/initial_state.rb', line 7 def initialize(configurator_state) @configurator_state = configurator_state end |
Instance Method Details
#load_scenarios ⇒ Object
11 12 13 |
# File 'lib/http_stub/server/memory/initial_state.rb', line 11 def load_scenarios @configurator_state.scenario_hashes.map { |hash| HttpStub::Server::Scenario.create(hash) } end |
#load_stubs(scenario_registry) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/http_stub/server/memory/initial_state.rb', line 15 def load_stubs(scenario_registry) initial_stubs = @configurator_state.stub_hashes.map { |hash| HttpStub::Server::Stub.create(hash) } activated_stubs = scenario_registry.find_all(&:initially_activated?).map do |activated_scenario| scenario_registry.stubs_activated_by(activated_scenario, HttpStub::Server::StdoutLogger) end.flatten initial_stubs + activated_stubs end |