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 ⇒ Object
MySQL has no NULLS FIRST/LAST, but Arel emulates it there with a leading IS NULL ordering, so these are portable.
- #nulls_last ⇒ Object
- #to_arel(table, model) ⇒ Object
Methods inherited from Node
Constructor Details
#initialize(operand, direction, nulls = nil) ⇒ Ordering
Returns a new instance of Ordering.
1144 1145 1146 1147 1148 |
# File 'lib/active_record/refined/ast.rb', line 1144 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.
1142 1143 1144 |
# File 'lib/active_record/refined/ast.rb', line 1142 def direction @direction end |
#nulls ⇒ Object (readonly)
Returns the value of attribute nulls.
1142 1143 1144 |
# File 'lib/active_record/refined/ast.rb', line 1142 def nulls @nulls end |
#operand ⇒ Object (readonly)
Returns the value of attribute operand.
1142 1143 1144 |
# File 'lib/active_record/refined/ast.rb', line 1142 def operand @operand end |
Instance Method Details
#nulls_first ⇒ Object
MySQL has no NULLS FIRST/LAST, but Arel emulates it there with a leading IS NULL ordering, so these are portable.
1152 1153 1154 |
# File 'lib/active_record/refined/ast.rb', line 1152 def nulls_first Ordering.new(operand, direction, :nulls_first) end |
#nulls_last ⇒ Object
1156 1157 1158 |
# File 'lib/active_record/refined/ast.rb', line 1156 def nulls_last Ordering.new(operand, direction, :nulls_last) end |
#to_arel(table, model) ⇒ Object
1160 1161 1162 1163 |
# File 'lib/active_record/refined/ast.rb', line 1160 def to_arel(table, model) ordering = to_arel_operand(operand, table, model).public_send(direction) nulls ? ordering.public_send(nulls) : ordering end |