Class: Terrestrial::QueryOrder

Inherits:
Object
  • Object
show all
Defined in:
lib/terrestrial/query_order.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_functionObject (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

#fieldsObject (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