method
construct_count_options_from_legacy_args
Ruby on Rails latest stable (v3.2.13)
-
0 notes -
Class: ActiveRecord::Calculations::ClassMethods
- 1.0.0
- 1.1.0
- 1.1.1
- 1.1.6
- 1.2.0 (0)
- 1.2.6 (0)
- 2.0.0
- 2.0.1
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.2
- 2.3.8
- 3.0.0
- 3.0.5
- 3.0.7
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.3
- 3.2.8
- 3.2.13
- What's this?
construct_count_options_from_legacy_args(*args)
protected
Hide source
# File activerecord/lib/active_record/calculations.rb, line 128 def construct_count_options_from_legacy_args(*args) options = {} column_name = :all # We need to handle # count() # count(options={}) # count(column_name=:all, options={}) # count(conditions=nil, joins=nil) # deprecated if args.size > 2 raise ArgumentError, "Unexpected parameters passed to count(options={}): #{args.inspect}" elsif args.size > 0 if args[0].is_a?(Hash) options = args[0] elsif args[1].is_a?(Hash) column_name, options = args else # Deprecated count(conditions, joins=nil) ActiveSupport::Deprecation.warn( "You called count(#{args[0].inspect}, #{args[1].inspect}), which is a deprecated API call. " + "Instead you should use count(column_name, options). Passing the conditions and joins as " + "string parameters will be removed in Rails 2.0.", caller(2) ) options.merge!(:conditions => args[0]) options.merge!(:joins => args[1]) if args[1] end end [column_name, options] end


