Sha256: 31bb5c23738d9c247064be60e178eb5d78cad37c0100883a4f1d6ee0a13bf653

Contents?: true

Size: 870 Bytes

Versions: 1

Compression:

Stored size: 870 Bytes

Contents

module ActiveRecord
  module NullRelation # :nodoc:
    def pluck(*column_names)
      []
    end

    def delete_all(_conditions = nil)
      0
    end

    def update_all(_updates)
      0
    end

    def delete(_id_or_array)
      0
    end

    def empty?
      true
    end

    def none?
      true
    end

    def any?
      false
    end

    def one?
      false
    end

    def many?
      false
    end

    def to_sql
      ""
    end

    def calculate(operation, _column_name)
      case operation
      when :count, :sum
        group_values.any? ? Hash.new : 0
      when :average, :minimum, :maximum
        group_values.any? ? Hash.new : nil
      end
    end

    def exists?(_conditions = :none)
      false
    end

    def or(other)
      other.spawn
    end

    private

      def exec_queries
        @records = [].freeze
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activerecord-5.1.0.beta1 lib/active_record/null_relation.rb