Module: PeriodicCalculations::Base::ClassMethods

Defined in:
lib/periodic_calculations/base.rb

Overview

TODO:

* Rails 4 compatible only right now (scoped vs all)

Instance Method Summary collapse

Instance Method Details

#periodic_average(*args) ⇒ Object



25
26
27
# File 'lib/periodic_calculations/base.rb', line 25

def periodic_average(*args)
  periodic_calculation(:avg, *args)
end

#periodic_calculation(operation, column_name, window_start, window_end, options = {}) ⇒ Object



29
30
31
32
33
# File 'lib/periodic_calculations/base.rb', line 29

def periodic_calculation(operation, column_name, window_start, window_end, options = {})
  query_options = QueryOptions.new(operation, column_name, window_start, window_end, options)
  query = Query.new(all, query_options)
  LazyQuery.new(query)
end

#periodic_count(*args) ⇒ Object



9
10
11
# File 'lib/periodic_calculations/base.rb', line 9

def periodic_count(*args)
  periodic_calculation(:count, *args)
end

#periodic_maximum(*args) ⇒ Object



13
14
15
# File 'lib/periodic_calculations/base.rb', line 13

def periodic_maximum(*args)
  periodic_calculation(:max, *args)
end

#periodic_minimum(*args) ⇒ Object



17
18
19
# File 'lib/periodic_calculations/base.rb', line 17

def periodic_minimum(*args)
  periodic_calculation(:min, *args)
end

#periodic_sum(*args) ⇒ Object



21
22
23
# File 'lib/periodic_calculations/base.rb', line 21

def periodic_sum(*args)
  periodic_calculation(:sum, *args)
end