Flowdock
method

construct_count_options_from_args

Importance_0
v2.3.2 - Show latest stable - 0 notes - Class: ActiveRecord::Calculations::ClassMethods
construct_count_options_from_args(*args) protected

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/calculations.rb, line 141
        def construct_count_options_from_args(*args)
          options     = {}
          column_name = :all

          # We need to handle
          #   count()
          #   count(:column_name=:all)
          #   count(options={})
          #   count(column_name=:all, options={})
          #   selects specified by scopes
          case args.size
          when 0
            column_name = scope(:find)[:select] if scope(:find)
          when 1
            if args[0].is_a?(Hash)
              column_name = scope(:find)[:select] if scope(:find)
              options = args[0]
            else
              column_name = args[0]
            end
          when 2
            column_name, options = args
          else
            raise ArgumentError, "Unexpected parameters passed to count(): #{args.inspect}"
          end

          [column_name || :all, options]
        end
Register or log in to add new notes.