Class: HttpStub::Configurer::DSL::StubBuilderTemplate
- Inherits:
-
Object
- Object
- HttpStub::Configurer::DSL::StubBuilderTemplate
- Defined in:
- lib/http_stub/configurer/dsl/stub_builder_template.rb
Instance Attribute Summary collapse
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #build_stub(response_overrides = {}, &block) ⇒ Object
-
#initialize(parent_template = nil, &block) ⇒ StubBuilderTemplate
constructor
A new instance of StubBuilderTemplate.
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
#template ⇒ Object (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 |