Module: Mongoid::Cacheable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/mongoid_cacheable.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
Instance Method Details
#cache_field(field_name, &block) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/mongoid_cacheable.rb', line 27 def cache_field(field_name, &block) unless read_attribute(field_name) # cache quitely with atomic set set field_name, yield end read_attribute(field_name) end |
#clear_cache_field(field_name) ⇒ Object
36 37 38 |
# File 'lib/mongoid_cacheable.rb', line 36 def clear_cache_field(field_name) unset field_name end |