aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_relation/primitives/scalar.rb
blob: d428541a509dfad40a4648c4f14283348292809f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module ActiveRelation
  class Scalar
    attr_reader :value, :relation
    
    def initialize(value, relation)
      @value, @relation = value, relation
    end
    
    def to_sql(strategy = Sql::Predicate.new(relation.engine))
      strategy.scalar value
    end

    def format(object)
      object.to_sql(Sql::Scalar.new(relation.engine))
    end
    
    def ==(other)
      value == other.value
    end
    
    def qualify
      self
    end
  end
end