Module: Cash::Finders::ClassMethods

Defined in:
lib/cash/finders.rb

Class Method Summary collapse

Instance Method Summary collapse

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, options = {})
  Query::Calculation.perform(self, operation, column_name, options, 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(options)
  Query::Select.perform(self, options, 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, options)
  Query::PrimaryKey.perform(self, ids, options, scope(:find))
end