Module: LazyAttributes::Relation

Defined in:
lib/lazy_attributes/relation.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(mod) ⇒ Object



3
4
5
6
7
8
# File 'lib/lazy_attributes/relation.rb', line 3

def self.included(mod)
  mod.class_eval do
    alias_method :original_calculate, :calculate
    alias_method :calculate, :calculate_without_select_values
  end
end

Instance Method Details

#calculate_without_select_values(operation, column_name, options = {}) ⇒ Object



10
11
12
13
14
15
# File 'lib/lazy_attributes/relation.rb', line 10

def calculate_without_select_values(operation, column_name, options = {})
  original_select_values, self.select_values = self.select_values, []
  original_calculate(operation, column_name, options)
ensure
  self.select_values = original_select_values
end