Module: RailheadCacheify::ClassMethods

Defined in:
lib/railhead_cacheify.rb

Instance Method Summary collapse

Instance Method Details

#cacheify(key, options = {}) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/railhead_cacheify.rb', line 29

def cacheify(key, options = {})
  class_eval "    alias _original_\#{key} \#{key}\n    def \#{key}(*args)\n      @\#{key} ||= read_cache(:\#{key}, \#{options[:expires_in] ? \"{expires_in: \#{options[:expires_in]}}\" : '{}'}) { _original_\#{key}(*args) }\n    end\n  END\nend\n"