Skip to content

Commit

Permalink
got rid of SUPPORTED_CALCULATIONS constant
Browse files Browse the repository at this point in the history
  • Loading branch information
alex committed May 26, 2009
1 parent 5102661 commit 28b513b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/statistics.rb
Expand Up @@ -7,10 +7,11 @@ def included(base)
def default_filters(filters)
ActiveRecord::Base.instance_eval { @filter_all_on = filters }
end

def supported_calculations
[:average, :count, :maximum, :minimum, :sum]
end
end

SUPPORTED_CALCULATIONS = [:average, :count, :maximum, :minimum, :sum]


# This extension provides the ability to define statistics for reporting purposes
module HasStats
Expand Down Expand Up @@ -48,7 +49,7 @@ def define_statistic(name, options)

options = { :column_name => :id }.merge(options)

calculation = options.keys.find {|opt| SUPPORTED_CALCULATIONS.include?(opt)}
calculation = options.keys.find {|opt| Statistics::supported_calculations.include?(opt)}
calculation ||= :count

# We must use the metaclass here to metaprogrammatically define a class method
Expand Down Expand Up @@ -154,7 +155,7 @@ def defined_stats(name)
end

def sql_options(options)
SUPPORTED_CALCULATIONS.each do |deletable|
Statistics::supported_calculations.each do |deletable|
options.delete(deletable)
end
options.delete(:column_name)
Expand Down

0 comments on commit 28b513b

Please sign in to comment.