Class: ApiResource::Decorators::CachingDecorator
- Inherits:
-
Object
- Object
- ApiResource::Decorators::CachingDecorator
- Defined in:
- lib/api_resource/decorators/caching_decorator.rb
Instance Attribute Summary collapse
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#ttl ⇒ Object
readonly
Returns the value of attribute ttl.
Instance Method Summary collapse
-
#initialize(owner, ttl) ⇒ CachingDecorator
constructor
A new instance of CachingDecorator.
- #method_missing(method_name, *args, &block) ⇒ Object
Constructor Details
#initialize(owner, ttl) ⇒ CachingDecorator
Returns a new instance of CachingDecorator.
7 8 9 10 |
# File 'lib/api_resource/decorators/caching_decorator.rb', line 7 def initialize(owner, ttl) @owner = owner @ttl = ttl end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
13 14 15 16 17 |
# File 'lib/api_resource/decorators/caching_decorator.rb', line 13 def method_missing(method_name, *args, &block) ApiResource.with_ttl(self.ttl) do self.owner.send(method_name, *args, &block) end end |
Instance Attribute Details
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
4 5 6 |
# File 'lib/api_resource/decorators/caching_decorator.rb', line 4 def owner @owner end |
#ttl ⇒ Object (readonly)
Returns the value of attribute ttl.
5 6 7 |
# File 'lib/api_resource/decorators/caching_decorator.rb', line 5 def ttl @ttl end |