Sha256: a2ea548530a5b4b83b1beaef3b3e927febe03d0ee6fff38c23cdd23b23b4a339
Contents?: true
Size: 802 Bytes
Versions: 4
Compression:
Stored size: 802 Bytes
Contents
require 'sanford-protocol' require 'and-son/response' module AndSon class StoredResponses RequestData = Struct.new(:name, :params) def initialize @hash = {} end def add(name, params = nil, &response_block) request_data = RequestData.new(name, params || {}) @hash[request_data] = response_block end def find(name, params = nil) response_block = @hash[RequestData.new(name, params || {})] return if !response_block response = response_block.call if !response.kind_of?(Sanford::Protocol::Response) response = Sanford::Protocol::Response.new(200, response) end AndSon::Response.new(response) end def remove(name, params = nil) @hash.delete(RequestData.new(name, params || {})) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
and-son-0.6.1 | lib/and-son/stored_responses.rb |
and-son-0.6.0 | lib/and-son/stored_responses.rb |
and-son-0.5.0 | lib/and-son/stored_responses.rb |
and-son-0.4.1 | lib/and-son/stored_responses.rb |