Class: Mockr::Response
Overview
:nodoc:
Instance Method Summary collapse
- #add_handler(handler) ⇒ Object
- #call(*args, &block) ⇒ Object
-
#initialize ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize ⇒ Response
Returns a new instance of Response.
161 162 163 |
# File 'lib/mockr.rb', line 161 def initialize @handlers = [] end |
Instance Method Details
#add_handler(handler) ⇒ Object
165 166 167 |
# File 'lib/mockr.rb', line 165 def add_handler(handler) @handlers << handler; handler end |
#call(*args, &block) ⇒ Object
169 170 171 172 173 174 175 |
# File 'lib/mockr.rb', line 169 def call(*args, &block) args << block if block @handlers.each do |handler| return handler.call if handler === args end raise AssertionFailedError.new("no match for arguments: #{args.inspect}") end |