Module: CacheValue::ClassMethods

Includes:
Util
Defined in:
lib/cache_value/cache_value.rb

Instance Method Summary collapse

Methods included from Util

#caching_method_names, #hex_digest

Instance Method Details

#cache_value(method, option) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/cache_value/cache_value.rb', line 8

def cache_value(method, option)
  without_method, with_method = caching_method_names(method)
  class_eval do
    define_method with_method do |*args|
      CacheValue::CacheMachine.lookup(self, method, option, args)
    end
    
    alias_method without_method, method
    alias_method method, with_method
  end
end