class Flexirest::CachedResponse
Attributes
class_name[RW]
etag[RW]
expires[RW]
response_headers[RW]
status[RW]
Public Class Methods
new(options)
click to toggle source
# File lib/flexirest/caching.rb, line 92 def initialize(options) @status = options[:status] @etag = options[:etag] @expires = options[:expires] @response_headers = options[:response_headers] @class_name = options[:result].class.name if options[:result].is_a?(ResultIterator) @class_name = options[:result][0].class.name @result = options[:result].map{|i| {}.merge(i._attributes)} else @result = {}.merge(options[:result].try(:_attributes) || {}) end end
Public Instance Methods
result()
click to toggle source
# File lib/flexirest/caching.rb, line 107 def result return @result if @class_name.nil? # Old cached instance if @result.is_a?(Array) ri = ResultIterator.new(self) ri.items = @result.map{|i| @class_name.constantize.new(i)} ri._clean! ri else obj = @class_name.constantize.new(@result) obj._clean! obj end end