Class: Arel::Order
- Defined in:
- lib/arel/algebra/relations/operations/order.rb
Instance Attribute Summary collapse
-
#orderings ⇒ Object
readonly
Returns the value of attribute orderings.
Attributes inherited from Compound
Attributes included from Relation
Instance Method Summary collapse
- #eval ⇒ Object
-
#initialize(relation, orderings) ⇒ Order
constructor
A new instance of Order.
-
#orders ⇒ Object
TESTME.
Methods inherited from Compound
#attributes, #column_for, #externalizable?, #join?, #joins, #name, #skipped, #sources, #table, #table_alias, #table_sql, #taken, #unoperated_rows
Methods included from Relation
#[], #alias, #attributes, #bind, #call, #christener, #compiler, #delete, #each, #exclusion_predicate_sql, #externalizable?, #externalize, #find_attribute_matching_name, #from, #from_clauses, #group_clauses, #groupings, #having_clauses, #havings, #inclusion_predicate_sql, #insert, #inserts, #join, #join?, #joins, #lock, #locked, #order_clauses, #outer_join, #position_of, #primary_key, #project, #projections, #select_clauses, #session, #skip, #skipped, #sources, #take, #taken, #to_sql, #update, #where, #where_clauses, #wheres
Constructor Details
#initialize(relation, orderings) ⇒ Order
Returns a new instance of Order.
5 6 7 8 |
# File 'lib/arel/algebra/relations/operations/order.rb', line 5 def initialize(relation, orderings) super(relation) @orderings = orderings.collect { |o| o.bind(relation) } end |
Instance Attribute Details
#orderings ⇒ Object (readonly)
Returns the value of attribute orderings.
3 4 5 |
# File 'lib/arel/algebra/relations/operations/order.rb', line 3 def orderings @orderings end |
Instance Method Details
#eval ⇒ Object
16 17 18 19 20 21 |
# File 'lib/arel/algebra/relations/operations/order.rb', line 16 def eval unoperated_rows.sort do |row1, row2| ordering = orders.detect { |o| o.eval(row1, row2) != 0 } || orders.last ordering.eval(row1, row2) end end |
#orders ⇒ Object
TESTME
11 12 13 14 |
# File 'lib/arel/algebra/relations/operations/order.rb', line 11 def orders # QUESTION - do we still need relation.orders ? (orderings + relation.orders).collect { |o| o.bind(self) }.collect { |o| o.to_ordering } end |