Class: HttpStub::Configurer::DSL::StubBuilderTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/http_stub/configurer/dsl/stub_builder_template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of StubBuilderTemplate.



11
12
13
# File 'lib/http_stub/configurer/dsl/stub_builder_template.rb', line 11

def initialize(parent_template=nil, &block)
  @template = HttpStub::Configurer::DSL::StubBuilder.new(parent_template.try(:template), &block)
end

Instance Attribute Details

#templateObject (readonly)

Returns the value of attribute template.



7
8
9
# File 'lib/http_stub/configurer/dsl/stub_builder_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/configurer/dsl/stub_builder_template.rb', line 15

def build_stub(response_overrides={}, &block)
  HttpStub::Configurer::DSL::StubBuilder.new(@template) do |stub|
    stub.respond_with(response_overrides)
    stub.invoke(&block) if block_given?
  end
end