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
# 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, 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(…)



23
24
25
# File 'lib/cash/finders.rb', line 23

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([])



28
29
30
# File 'lib/cash/finders.rb', line 28

def find_from_ids_with_cache(ids, options)
  Query::PrimaryKey.perform(self, ids, options, 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