aboutsummaryrefslogblamecommitdiffstats
path: root/lib/arel/primitives/value.rb
blob: 5142eb45ca83c25f107dfc5bcafb4374f091526a (plain) (tree)
1
2
3
4
5
6
7
8
9
10
           
             

                                 
                                                                             
    



                                         
                                                             
                           

       
                      
                                             





                          


                                

     
module Arel
  class Value
    attr_reader :value, :relation
    
    delegate :inclusion_predicate_sql, :equality_predicate_sql, :to => :value
    
    def initialize(value, relation)
      @value, @relation = value, relation
    end
    
    def to_sql(formatter = Sql::WhereCondition.new(relation))
      formatter.value value
    end

    def format(object)
      object.to_sql(Sql::Value.new(relation))
    end
    
    def ==(other)
      value == other.value
    end
    
    def bind(relation)
      Value.new(value, relation)
    end
  end
end