Class: HttpStub::Configurator::Stub::Template
- Inherits:
-
Object
- Object
- HttpStub::Configurator::Stub::Template
- Defined in:
- lib/http_stub/configurator/stub/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) ⇒ Template
constructor
A new instance of Template.
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
#template ⇒ Object (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 |