Module: Bodhi::AggregateMetrics

Included in:
Metric
Defined in:
lib/bodhi/definitions/aggregate.rb

Instance Method Summary collapse

Instance Method Details

#aggregate(*args) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/bodhi/definitions/aggregate.rb', line 19

def aggregate (*args)
  options = args.extract_options!

  agg_method = args[0]
  options[:model_name] = args[1]
  field = args[2]

  options[:block] = get_agg_block(agg_method, field)
  options[:name] ||= "#{options[:model_name]}_#{agg_method}_#{field}"

  define(options)
end

#average(*args) ⇒ Object



3
4
5
# File 'lib/bodhi/definitions/aggregate.rb', line 3

def average (*args)
  aggregate *args.unshift(:average)
end

#maximum(*args) ⇒ Object



11
12
13
# File 'lib/bodhi/definitions/aggregate.rb', line 11

def maximum (*args)
  aggregate *args.unshift(:maximum)
end

#minimum(*args) ⇒ Object



15
16
17
# File 'lib/bodhi/definitions/aggregate.rb', line 15

def minimum (*args)
  aggregate *args.unshift(:minimum)
end

#sum(*args) ⇒ Object



7
8
9
# File 'lib/bodhi/definitions/aggregate.rb', line 7

def sum (*args)
  aggregate *args.unshift(:sum)
end