Sha256: 057d7d2f06535c222f7bbbbe79d934140a8f96173a92a675a4c666006781653a

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

module ActiveRecord
  module NullRelation # :nodoc:
    def exec_queries
      @records = []
    end
    def pluck(*column_names)
      []
    end
    def delete_all(_conditions = nil)
      0
    end
    def update_all(_updates, _conditions = nil, _options = {})
      0
    end
    def delete(_id_or_array)
      0
    end
    def size
      calculate :size, nil
    end
    def empty?
      true
    end
    def any?
      false
    end
    def many?
      false
    end
    def to_sql
      ""
    end
    def count(*)
      calculate :count, nil
    end
    def sum(*)
      calculate :sum, nil
    end
    def average(*)
      calculate :average, nil
    end
    def minimum(*)
      calculate :minimum, nil
    end
    def maximum(*)
      calculate :maximum, nil
    end
    def calculate(operation, _column_name, _options = {})
      # TODO: Remove _options argument as soon we remove support to
      # activerecord-deprecated_finders.
      if [:count, :sum, :size].include? operation
        group_values.any? ? Hash.new : 0
      elsif [:average, :minimum, :maximum].include?(operation) && group_values.any?
        Hash.new
      else
        nil
      end
    end

    def exists?(_id = false)
      false
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_backward-0.0.2 lib/rails_backward/null_relation.rb