aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/engines/memory/primitives.rb
blob: 935b34f5ee4907cd8efbfec243c7ba790583893e (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
26
27
module Arel
  class Attribute
    def eval(row)
      row[self]
    end
  end

  class Value
    def eval(row)
      value
    end
  end

  class Ordering
    def eval(row1, row2)
      (attribute.eval(row1) <=> attribute.eval(row2)) * direction
    end
  end

  class Descending < Ordering
    def direction; -1 end
  end

  class Ascending < Ordering
    def direction; 1 end
  end
end