Module: Memcacheable::ClassMethods
- Defined in:
- lib/memcacheable.rb
Instance Method Summary collapse
- #cache_belongs_to(association) ⇒ Object
- #cache_has_many(association) ⇒ Object
- #cache_has_one(association) ⇒ Object
- #cache_index(*fields) ⇒ Object
- #fetch(id) ⇒ Object
- #fetch_by(*args) ⇒ Object
- #fetch_by!(*args) ⇒ Object
- #fetch_where(*args) ⇒ Object
Instance Method Details
#cache_belongs_to(association) ⇒ Object
33 34 35 36 37 |
# File 'lib/memcacheable.rb', line 33 def cache_belongs_to(association) define_method "fetch_#{association}" do FetchBelongsTo.new(self, association).fetch end end |
#cache_has_many(association) ⇒ Object
45 46 47 48 49 |
# File 'lib/memcacheable.rb', line 45 def cache_has_many(association) define_method "fetch_#{association}" do FetchHasMany.new(self, association).fetch end end |
#cache_has_one(association) ⇒ Object
39 40 41 42 43 |
# File 'lib/memcacheable.rb', line 39 def cache_has_one(association) define_method "fetch_#{association}" do FetchHasOne.new(self, association).fetch end end |
#cache_index(*fields) ⇒ Object
51 52 53 |
# File 'lib/memcacheable.rb', line 51 def cache_index(*fields) self.cached_indexes << fields.map(&:to_sym).sort end |
#fetch(id) ⇒ Object
55 56 57 |
# File 'lib/memcacheable.rb', line 55 def fetch(id) FetchOne.new(self, id).fetch end |
#fetch_by(*args) ⇒ Object
59 60 61 |
# File 'lib/memcacheable.rb', line 59 def fetch_by(*args) FetchBy.new(self, *args).fetch end |
#fetch_by!(*args) ⇒ Object
63 64 65 |
# File 'lib/memcacheable.rb', line 63 def fetch_by!(*args) fetch_by(*args) || raise(ActiveRecord::RecordNotFound) end |
#fetch_where(*args) ⇒ Object
67 68 69 |
# File 'lib/memcacheable.rb', line 67 def fetch_where(*args) FetchWhere.new(self, *args).fetch end |