From 9465b84b543ae1ada29c0e39e34f919c724eab6d Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Tue, 19 Jan 2010 22:15:35 +0530 Subject: [PATCH] Rename CalculationMethods to Calculations and get rid of the old Calculations module --- activerecord/lib/active_record.rb | 3 +-- activerecord/lib/active_record/base.rb | 3 ++- activerecord/lib/active_record/calculations.rb | 9 --------- activerecord/lib/active_record/relation.rb | 2 +- .../relation/{calculation_methods.rb => calculations.rb} | 2 +- 5 files changed, 5 insertions(+), 14 deletions(-) delete mode 100644 activerecord/lib/active_record/calculations.rb rename activerecord/lib/active_record/relation/{calculation_methods.rb => calculations.rb} (99%) diff --git a/activerecord/lib/active_record.rb b/activerecord/lib/active_record.rb index d5b6d40514e3a..58673ab7bd385 100644 --- a/activerecord/lib/active_record.rb +++ b/activerecord/lib/active_record.rb @@ -53,14 +53,13 @@ module ActiveRecord autoload_under 'relation' do autoload :QueryMethods autoload :FinderMethods - autoload :CalculationMethods + autoload :Calculations autoload :PredicateBuilder autoload :SpawnMethods end autoload :Base autoload :Batches - autoload :Calculations autoload :Callbacks autoload :DynamicFinderMatch autoload :DynamicScopeMatch diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 06244d1132ad9..e10df1abd3b1c 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -654,6 +654,7 @@ def find(*args) end delegate :select, :group, :order, :limit, :joins, :where, :preload, :eager_load, :includes, :from, :lock, :readonly, :having, :to => :scoped + delegate :count, :average, :minimum, :maximum, :sum, :calculate, :to => :scoped # A convenience wrapper for find(:first, *args). You can pass in all the # same arguments to this method as you can to find(:first). @@ -2742,7 +2743,7 @@ def quoted_comma_pair_list(quoter, hash) # #save_with_autosave_associations to be wrapped inside a transaction. include AutosaveAssociation, NestedAttributes - include Aggregations, Transactions, Reflection, Batches, Calculations, Serialization + include Aggregations, Transactions, Reflection, Batches, Serialization end end diff --git a/activerecord/lib/active_record/calculations.rb b/activerecord/lib/active_record/calculations.rb deleted file mode 100644 index ea63617c52f5f..0000000000000 --- a/activerecord/lib/active_record/calculations.rb +++ /dev/null @@ -1,9 +0,0 @@ -module ActiveRecord - module Calculations #:nodoc: - extend ActiveSupport::Concern - - module ClassMethods - delegate :count, :average, :minimum, :maximum, :sum, :calculate, :to => :scoped - end - end -end diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 19f91f4278c0f..6ac7137976df2 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -5,7 +5,7 @@ class Relation MULTI_VALUE_METHODS = [:select, :group, :order, :joins, :where, :having] SINGLE_VALUE_METHODS = [:limit, :offset, :lock, :readonly, :create_with, :from] - include FinderMethods, CalculationMethods, SpawnMethods, QueryMethods + include FinderMethods, Calculations, SpawnMethods, QueryMethods delegate :length, :collect, :map, :each, :all?, :include?, :to => :to_a diff --git a/activerecord/lib/active_record/relation/calculation_methods.rb b/activerecord/lib/active_record/relation/calculations.rb similarity index 99% rename from activerecord/lib/active_record/relation/calculation_methods.rb rename to activerecord/lib/active_record/relation/calculations.rb index 155e90333c9dc..5645e7f031320 100644 --- a/activerecord/lib/active_record/relation/calculation_methods.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -1,5 +1,5 @@ module ActiveRecord - module CalculationMethods + module Calculations # Count operates using three different approaches. # # * Count all: By not passing any parameters to count, it will return a count of all the rows for the model.