Class: Flexirest::CachedResponse
- Inherits:
-
Object
- Object
- Flexirest::CachedResponse
- Defined in:
- lib/flexirest/caching.rb
Instance Attribute Summary collapse
-
#class_name ⇒ Object
Returns the value of attribute class_name.
-
#etag ⇒ Object
Returns the value of attribute etag.
-
#expires ⇒ Object
Returns the value of attribute expires.
-
#response_headers ⇒ Object
Returns the value of attribute response_headers.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(options) ⇒ CachedResponse
constructor
A new instance of CachedResponse.
- #result ⇒ Object
Constructor Details
#initialize(options) ⇒ CachedResponse
Returns a new instance of CachedResponse.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/flexirest/caching.rb', line 100 def initialize() @status = [:status] @etag = [:etag] @expires = [:expires] @response_headers = [:response_headers] @old_cached_instance = [:result].class.name.nil? if [:result].is_a?(ResultIterator) @class_name = [:result][0].class.name @result = [:result].map{|i| {}.merge(i._attributes)} else @class_name = [:class_name] @result = {}.merge([:result].try(:_attributes) || {}) end end |
Instance Attribute Details
#class_name ⇒ Object
Returns the value of attribute class_name.
98 99 100 |
# File 'lib/flexirest/caching.rb', line 98 def class_name @class_name end |
#etag ⇒ Object
Returns the value of attribute etag.
98 99 100 |
# File 'lib/flexirest/caching.rb', line 98 def etag @etag end |
#expires ⇒ Object
Returns the value of attribute expires.
98 99 100 |
# File 'lib/flexirest/caching.rb', line 98 def expires @expires end |
#response_headers ⇒ Object
Returns the value of attribute response_headers.
98 99 100 |
# File 'lib/flexirest/caching.rb', line 98 def response_headers @response_headers end |
#status ⇒ Object
Returns the value of attribute status.
98 99 100 |
# File 'lib/flexirest/caching.rb', line 98 def status @status end |
Instance Method Details
#result ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# 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 |