Class: Caching::Proxy
- Inherits:
-
Object
- Object
- Caching::Proxy
- Defined in:
- lib/caching/proxy.rb
Instance Method Summary collapse
- #clear_cache(*methods) ⇒ Object
-
#initialize(target, *methods) ⇒ Proxy
constructor
A new instance of Proxy.
- #method_missing(method, *args, &block) ⇒ Object
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/caching/proxy.rb', line 12 def method_missing(method, *args, &block) if @methods.include? method.to_sym @storage.fetch(method) { @target.send(method, *args, &block) } else @target.send(method, *args, &block) end end |
Instance Method Details
#clear_cache(*methods) ⇒ Object
20 21 22 |
# File 'lib/caching/proxy.rb', line 20 def clear_cache(*methods) @storage.clear *methods end |