Class: ActiveRecord::Refined::AST::Ordering
- Defined in:
- lib/active_record/refined/ast.rb
Instance Attribute Summary collapse
-
#direction ⇒ Object
readonly
Returns the value of attribute direction.
-
#nulls ⇒ Object
readonly
Returns the value of attribute nulls.
-
#operand ⇒ Object
readonly
Returns the value of attribute operand.
Instance Method Summary collapse
-
#initialize(operand, direction, nulls = nil) ⇒ Ordering
constructor
A new instance of Ordering.
-
#nulls_first ⇒ AST::Ordering
NULLS FIRST; portable, since Arel emulates it where MySQL has none. -
#nulls_last ⇒ AST::Ordering
NULLS LAST. - #to_arel(table, model) ⇒ Object
Methods inherited from Node
Constructor Details
#initialize(operand, direction, nulls = nil) ⇒ Ordering
Returns a new instance of Ordering.
1842 1843 1844 1845 1846 |
# File 'lib/active_record/refined/ast.rb', line 1842 def initialize(operand, direction, nulls = nil) @operand = operand @direction = direction @nulls = nulls end |
Instance Attribute Details
#direction ⇒ Object (readonly)
Returns the value of attribute direction.
1840 1841 1842 |
# File 'lib/active_record/refined/ast.rb', line 1840 def direction @direction end |
#nulls ⇒ Object (readonly)
Returns the value of attribute nulls.
1840 1841 1842 |
# File 'lib/active_record/refined/ast.rb', line 1840 def nulls @nulls end |
#operand ⇒ Object (readonly)
Returns the value of attribute operand.
1840 1841 1842 |
# File 'lib/active_record/refined/ast.rb', line 1840 def operand @operand end |
Instance Method Details
#nulls_first ⇒ AST::Ordering
NULLS FIRST; portable, since Arel emulates it where MySQL has
none.
MySQL has no NULLS FIRST/LAST, but Arel emulates it there with a
leading IS NULL ordering, so these are portable.
1854 1855 1856 |
# File 'lib/active_record/refined/ast.rb', line 1854 def nulls_first Ordering.new(operand, direction, :nulls_first) end |
#nulls_last ⇒ AST::Ordering
NULLS LAST.
1860 1861 1862 |
# File 'lib/active_record/refined/ast.rb', line 1860 def nulls_last Ordering.new(operand, direction, :nulls_last) end |
#to_arel(table, model) ⇒ Object
1864 1865 1866 1867 |
# File 'lib/active_record/refined/ast.rb', line 1864 def to_arel(table, model) ordering = to_arel_operand(operand, table, model).public_send(direction) nulls ? ordering.public_send(nulls) : ordering end |