class AndSon::StoredResponses::Stub
Attributes
hash[R]
Public Class Methods
new()
click to toggle source
# File lib/and-son/stored_responses.rb, line 32 def initialize @default_proc = proc{ |r| r.data = Hash.new } @hash = {} end
Public Instance Methods
call(params)
click to toggle source
# File lib/and-son/stored_responses.rb, line 46 def call(params) block = @hash[params] || @default_proc if block.arity == 0 || block.arity == -1 default_response.tap{ |r| r.data = block.call } else default_response.tap{ |r| block.call(r) } end end
set_default_proc(&block)
click to toggle source
# File lib/and-son/stored_responses.rb, line 37 def set_default_proc(&block) @default_proc = block if block end
with(params, &block)
click to toggle source
# File lib/and-son/stored_responses.rb, line 41 def with(params, &block) @hash[params] = block self end
Private Instance Methods
default_response()
click to toggle source
# File lib/and-son/stored_responses.rb, line 57 def default_response Sanford::Protocol::Response.new(200, {}) end