Module: Cash::Finders::ClassMethods
- Defined in:
- lib/cash/finders.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#calculate_with_cache(operation, column_name, options = {}) ⇒ Object
User.count(:all), User.count, User.sum(…).
-
#find_every_with_cache(options) ⇒ Object
User.find(:first, …), User.find_by_foo(…), User.find(:all, …), User.find_all_by_foo(…).
-
#find_from_ids_with_cache(ids, options) ⇒ Object
User.find(1), User.find(1, 2, 3), User.find([1, 2, 3]), User.find([]).
- #without_cache(&block) ⇒ Object
Class Method Details
.extended(active_record_class) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/cash/finders.rb', line 10 def self.extended(active_record_class) class << active_record_class alias_method_chain :find_every, :cache alias_method_chain :find_from_ids, :cache alias_method_chain :calculate, :cache end end |
Instance Method Details
#calculate_with_cache(operation, column_name, options = {}) ⇒ Object
User.count(:all), User.count, User.sum(…)
33 34 35 |
# File 'lib/cash/finders.rb', line 33 def calculate_with_cache(operation, column_name, = {}) Query::Calculation.perform(self, operation, column_name, , scope(:find)) end |
#find_every_with_cache(options) ⇒ Object
User.find(:first, …), User.find_by_foo(…), User.find(:all, …), User.find_all_by_foo(…)
23 24 25 |
# File 'lib/cash/finders.rb', line 23 def find_every_with_cache() Query::Select.perform(self, , scope(:find)) end |
#find_from_ids_with_cache(ids, options) ⇒ Object
User.find(1), User.find(1, 2, 3), User.find([1, 2, 3]), User.find([])
28 29 30 |
# File 'lib/cash/finders.rb', line 28 def find_from_ids_with_cache(ids, ) Query::PrimaryKey.perform(self, ids, , scope(:find)) end |
#without_cache(&block) ⇒ Object
18 19 20 |
# File 'lib/cash/finders.rb', line 18 def without_cache(&block) with_scope(:find => {:readonly => true}, &block) end |