Module: Mongoid::Cacheable::ClassMethods
- Defined in:
- lib/mongoid_cacheable.rb
Instance Method Summary collapse
Instance Method Details
#cache(name, *options) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mongoid_cacheable.rb', line 10 def cache( name, * ) field_name = "_#{name}" cached_name = "cached_#{name}" clear_cached_name = "clear_cached_#{name}" field field_name, * define_method(cached_name) do cache_field(field_name, &method(name)) end define_method(clear_cached_name) do clear_cache_field(field_name) end end |