Sha256: 0b33e684faad0d6cd41c22db9cf3d31010fb9a32930e0ab292e5ae6c9a0e05d5

Contents?: true

Size: 926 Bytes

Versions: 3

Compression:

Stored size: 926 Bytes

Contents

module Arel
  class Value
    attr_reader :value, :relation

    def initialize value, relation
      @value = value
      @relation = relation
    end

    def == other
      super ||
        Value === other &&
        value == other.value &&
        relation == other.relation
    end

    def eval(row)
      value
    end

    def bind(relation)
      Value.new(value, relation)
    end

    def to_ordering
      self
    end

    def inclusion_predicate_sql
      value.inclusion_predicate_sql
    end

    def exclusion_predicate_sql
      value.exclusion_predicate_sql
    end

    def equality_predicate_sql
      value.equality_predicate_sql
    end

    def inequality_predicate_sql
      value.inequality_predicate_sql
    end

    def to_sql(formatter = Sql::WhereCondition.new(relation))
      formatter.value value
    end

    def format(object)
      object.to_sql(Sql::Value.new(relation))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
arel-1.0.1 lib/arel/algebra/value.rb
arel-1.0.0 lib/arel/algebra/value.rb
arel-1.0.0.rc1 lib/arel/algebra/value.rb