Class: HttpStub::Server::Stub::Triggers

Inherits:
Object
  • Object
show all
Defined in:
lib/http_stub/server/stub/triggers.rb

Constant Summary collapse

EMPTY =
HttpStub::Server::Stub::Triggers.new.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Triggers

Returns a new instance of Triggers.



10
11
12
13
14
15
# File 'lib/http_stub/server/stub/triggers.rb', line 10

def initialize(args={})
  resolved_args = { "scenario_names" => [], "stubs" => [] }.merge(args || {})
  @scenario_names = resolved_args["scenario_names"]
  @stubs          = resolved_args["stubs"].map { |stub_args| HttpStub::Server::Stub.create(stub_args) }
  @description    = resolved_args.to_s
end

Instance Attribute Details

#scenario_namesObject (readonly)

Returns the value of attribute scenario_names.



7
8
9
# File 'lib/http_stub/server/stub/triggers.rb', line 7

def scenario_names
  @scenario_names
end

#stubsObject (readonly)

Returns the value of attribute stubs.



8
9
10
# File 'lib/http_stub/server/stub/triggers.rb', line 8

def stubs
  @stubs
end

Instance Method Details

#to_json(*args) ⇒ Object



19
20
21
# File 'lib/http_stub/server/stub/triggers.rb', line 19

def to_json(*args)
  { scenario_names: @scenario_names, stubs: @stubs }.to_json(*args)
end

#to_sObject



23
24
25
# File 'lib/http_stub/server/stub/triggers.rb', line 23

def to_s
  @description
end