class Flexirest::CachedResponse
Attributes
Public Class Methods
Source
# File lib/flexirest/caching.rb, line 100 def initialize(options) @status = options[:status] @etag = options[:etag] @expires = options[:expires] @response_headers = options[:response_headers] @old_cached_instance = options[:result].class.name.nil? if options[:result].is_a?(ResultIterator) @class_name = options[:result][0].class.name @result = options[:result].map{|i| {}.merge(i._attributes)} else @class_name = options[:class_name] @result = {}.merge(options[:result].try(:_attributes) || {}) end end
Public Instance Methods
Source
# File lib/flexirest/caching.rb, line 116 def result return @result if @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