class MSS::Core::ResponseCache
@api private
Attributes
cached_responses[R]
resource_cache[R]
Public Class Methods
new()
click to toggle source
# File lib/mss/core/response_cache.rb, line 23 def initialize @cached_responses = [] @indexed_responses = {} @resource_cache = ResourceCache.new end
Public Instance Methods
add(resp)
click to toggle source
# File lib/mss/core/response_cache.rb, line 29 def add(resp) cached_responses.unshift(resp) @indexed_responses[resp.cache_key] = resp if resp.respond_to?(:cache_key) @resource_cache = ResourceCache.new end
cached(resp)
click to toggle source
# File lib/mss/core/response_cache.rb, line 43 def cached(resp) @indexed_responses[resp.cache_key] end
select(*types, &block)
click to toggle source
# File lib/mss/core/response_cache.rb, line 36 def select(*types, &block) cached_responses.select do |resp| types.map{|t| t.to_s }.include?(resp.request_type.to_s) and (block.nil? || block.call(resp)) end end