method
construct_count_options_from_legacy_args
v1.2.6 -
Show latest stable
-
0 notes -
Class: ActiveRecord::Calculations::ClassMethods
- 1.0.0
- 1.1.6
- 1.2.6 (0)
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7
- 5.2.3
- 6.0.0
- 6.1.3.1
- 6.1.7.7
- 7.0.0
- 7.1.3.2
- 7.1.3.4
- 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