Class: BuckyBox::API::CachedResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/buckybox/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_atObject (readonly)

Returns the value of attribute cached_at.



12
13
14
# File 'lib/buckybox/api.rb', line 12

def cached_at
  @cached_at
end

#responseObject (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

Returns:

  • (Boolean)


18
19
20
# File 'lib/buckybox/api.rb', line 18

def expired?
  epoch - cached_at > 60 # NOTE: cache responses for 60 seconds
end