Method: Warped::Queries::Sort#initialize

Defined in:
lib/warped/queries/sort.rb

#initialize(scope, sort_key:, sort_direction: :desc) ⇒ ActiveRecord::Relation

Returns the sorted scope.

Parameters:

  • scope (ActiveRecord::Relation)

    the scope to sort

  • sort_key (String, Symbol)

    the key to sort by

  • sort_direction (String, Symbol) (defaults to: :desc)

    the direction to sort by



36
37
38
39
40
41
# File 'lib/warped/queries/sort.rb', line 36

def initialize(scope, sort_key:, sort_direction: :desc)
  super()
  @scope = scope
  @sort_key = sort_key.to_s
  @sort_direction = sort_direction.to_s.downcase
end