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([]).
Class Method Details
.extended(active_record_class) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/cash/finders.rb', line 10 def self.extended(active_record_class) active_record_class.class_eval do class << self alias_method_chain :find_every, :cache alias_method_chain :find_from_ids, :cache alias_method_chain :calculate, :cache end end end |
Instance Method Details
#calculate_with_cache(operation, column_name, options = {}) ⇒ Object
User.count(:all), User.count, User.sum(…)
31 32 33 |
# File 'lib/cash/finders.rb', line 31 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(…)
21 22 23 |
# File 'lib/cash/finders.rb', line 21 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([])
26 27 28 |
# File 'lib/cash/finders.rb', line 26 def find_from_ids_with_cache(ids, ) Query::PrimaryKey.perform(self, ids, , scope(:find)) end |