Class: Terrestrial::QueryOrder
- Inherits:
-
Object
- Object
- Terrestrial::QueryOrder
- Defined in:
- lib/terrestrial/query_order.rb
Instance Attribute Summary collapse
-
#direction_function ⇒ Object
readonly
Returns the value of attribute direction_function.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
Instance Method Summary collapse
- #apply(dataset) ⇒ Object
-
#initialize(fields:, direction:) ⇒ QueryOrder
constructor
A new instance of QueryOrder.
Constructor Details
#initialize(fields:, direction:) ⇒ QueryOrder
Returns a new instance of QueryOrder.
3 4 5 6 |
# File 'lib/terrestrial/query_order.rb', line 3 def initialize(fields:, direction:) @fields = fields @direction_function = get_direction_function(direction.to_s.upcase) end |
Instance Attribute Details
#direction_function ⇒ Object (readonly)
Returns the value of attribute direction_function.
8 9 10 |
# File 'lib/terrestrial/query_order.rb', line 8 def direction_function @direction_function end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
8 9 10 |
# File 'lib/terrestrial/query_order.rb', line 8 def fields @fields end |
Instance Method Details
#apply(dataset) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/terrestrial/query_order.rb', line 10 def apply(dataset) if fields.any? apply_direction(dataset.order(fields)) else dataset end end |