Class: HttpStub::Server::Stub::Response::Blocks
- Inherits:
-
Object
- Object
- HttpStub::Server::Stub::Response::Blocks
- Defined in:
- lib/http_stub/server/stub/response/blocks.rb
Instance Method Summary collapse
- #evaluate_with(request) ⇒ Object
-
#initialize(blocks) ⇒ Blocks
constructor
A new instance of Blocks.
- #to_array ⇒ Object
Constructor Details
#initialize(blocks) ⇒ Blocks
Returns a new instance of Blocks.
10 11 12 |
# File 'lib/http_stub/server/stub/response/blocks.rb', line 10 def initialize(blocks) @blocks = blocks || [] end |
Instance Method Details
#evaluate_with(request) ⇒ Object
14 15 16 |
# File 'lib/http_stub/server/stub/response/blocks.rb', line 14 def evaluate_with(request) @blocks.reduce({}) { |result, block| result.deep_merge(call_block(block, request)) } end |
#to_array ⇒ Object
18 19 20 |
# File 'lib/http_stub/server/stub/response/blocks.rb', line 18 def to_array @blocks.map(&:source) end |