aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/engines/memory/primitives.rb
blob: f8bbcedb556d8b0b5c98e16b3d0ce8ab5a3c88f6 (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