Module: BabySqueel::ActiveRecord::Calculations

Defined in:
lib/baby_squeel/active_record/calculations.rb

Instance Method Summary collapse

Instance Method Details

#averaging(&block) ⇒ Object



19
20
21
# File 'lib/baby_squeel/active_record/calculations.rb', line 19

def averaging(&block)
  average Calculation.new(DSL.evaluate(self, &block))
end

#counting(&block) ⇒ Object



11
12
13
# File 'lib/baby_squeel/active_record/calculations.rb', line 11

def counting(&block)
  count Calculation.new(DSL.evaluate(self, &block))
end

#maximizing(&block) ⇒ Object



27
28
29
# File 'lib/baby_squeel/active_record/calculations.rb', line 27

def maximizing(&block)
  maximum Calculation.new(DSL.evaluate(self, &block))
end

#minimizing(&block) ⇒ Object



23
24
25
# File 'lib/baby_squeel/active_record/calculations.rb', line 23

def minimizing(&block)
  minimum Calculation.new(DSL.evaluate(self, &block))
end

#plucking(&block) ⇒ Object



6
7
8
9
# File 'lib/baby_squeel/active_record/calculations.rb', line 6

def plucking(&block)
  nodes = Array.wrap(DSL.evaluate(self, &block))
  pluck(*nodes)
end

#summing(&block) ⇒ Object



15
16
17
# File 'lib/baby_squeel/active_record/calculations.rb', line 15

def summing(&block)
  sum Calculation.new(DSL.evaluate(self, &block))
end