Module: Ultracache::Macro::ClassMethods
- Defined in:
- lib/ultracache/macro.rb
Instance Method Summary collapse
- #cached_queue_in(another, options = {}, &block) ⇒ Object
- #has_cached_attribute(name, options = {}, &block) ⇒ Object
- #has_cached_queue(another, options = {}) ⇒ Object
Instance Method Details
#cached_queue_in(another, options = {}, &block) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/ultracache/macro.rb', line 6 def cached_queue_in(another, ={}, &block) name = [:as] ? [:as] : self.to_s.underscore relationship = BelongsAsCachedQueue.new name, block, :self_class => self, :need_update => [:need_update], :unless => [:unless], :associated_class => another self.relationships(:strict => true).add(relationship) end |
#has_cached_attribute(name, options = {}, &block) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/ultracache/macro.rb', line 26 def has_cached_attribute(name, ={}, &block) relationship = HasCachedAttribute.new name, block, :self_class => self, :serializer => [:serializer] self.relationships(:strict => true).add(relationship) define_method name do |*| read_cache(name, .first || {}) end end |
#has_cached_queue(another, options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ultracache/macro.rb', line 15 def has_cached_queue(another, ={}) relationship = HasCachedQueue.new another, :self_class => self, :associated_class => [:class] ? [:class] : another self.relationships(:strict => true).add(relationship) define_method another do |*| read_cache(another, .first || {}) end end |