Class: BuckyBox::API::CachedResponse
- Inherits:
-
Object
- Object
- BuckyBox::API::CachedResponse
- Defined in:
- lib/buckybox/api.rb
Instance Attribute Summary collapse
-
#cached_at ⇒ Object
readonly
Returns the value of attribute cached_at.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #expired? ⇒ Boolean
-
#initialize(response) ⇒ CachedResponse
constructor
A new instance of CachedResponse.
Constructor Details
#initialize(response) ⇒ CachedResponse
Returns a new instance of CachedResponse.
14 15 16 |
# File 'lib/buckybox/api.rb', line 14 def initialize(response) @response, @cached_at = response, epoch end |
Instance Attribute Details
#cached_at ⇒ Object (readonly)
Returns the value of attribute cached_at.
12 13 14 |
# File 'lib/buckybox/api.rb', line 12 def cached_at @cached_at end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
12 13 14 |
# File 'lib/buckybox/api.rb', line 12 def response @response end |
Instance Method Details
#expired? ⇒ Boolean
18 19 20 |
# File 'lib/buckybox/api.rb', line 18 def expired? epoch - cached_at > 60 # NOTE: cache responses for 60 seconds end |