Class: Arel::Ordering

Inherits:
Struct
  • Object
show all
Defined in:
lib/arel/algebra/ordering.rb

Direct Known Subclasses

Ascending, Descending

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attributeObject

Returns the value of attribute attribute

Returns:

  • (Object)

    the current value of attribute



2
3
4
# File 'lib/arel/algebra/ordering.rb', line 2

def attribute
  @attribute
end

Instance Method Details

#bind(relation) ⇒ Object



5
6
7
# File 'lib/arel/algebra/ordering.rb', line 5

def bind(relation)
  self.class.new(attribute.bind(relation))
end

#eval(row1, row2) ⇒ Object



13
14
15
# File 'lib/arel/algebra/ordering.rb', line 13

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

#to_orderingObject



9
10
11
# File 'lib/arel/algebra/ordering.rb', line 9

def to_ordering
  self
end

#to_sql(formatter = Sql::OrderClause.new(relation)) ⇒ Object



17
18
19
# File 'lib/arel/algebra/ordering.rb', line 17

def to_sql(formatter = Sql::OrderClause.new(relation))
  formatter.ordering self
end