Class: HttpStub::Configurator::Stub::Template

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent_template = nil, &block) ⇒ Template

Returns a new instance of Template.


11
12
13
# File 'lib/http_stub/configurator/stub/template.rb', line 11

def initialize(parent_template=nil, &block)
  @template = HttpStub::Configurator::Stub.create(parent_template.try(:template), &block)
end

Instance Attribute Details

#templateObject (readonly)

Returns the value of attribute template


7
8
9
# File 'lib/http_stub/configurator/stub/template.rb', line 7

def template
  @template
end

Instance Method Details

#build_stub(response_overrides = {}, &block) ⇒ Object


15
16
17
18
19
20
# File 'lib/http_stub/configurator/stub/template.rb', line 15

def build_stub(response_overrides={}, &block)
  HttpStub::Configurator::Stub.create(@template) do |stub|
    stub.respond_with(response_overrides)
    stub.invoke(&block) if block_given?
  end
end