Class: Jsonapi::QueryBuilder::BaseSort

Inherits:
Object
  • Object
show all
Defined in:
lib/jsonapi/query_builder/base_sort.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection, direction = :asc) ⇒ BaseSort

Returns a new instance of BaseSort.

Parameters:

  • collection (ActiveRecord::Relation)
  • direction (Symbol) (defaults to: :asc)

    of the ordering, one of :asc or :desc



10
11
12
13
# File 'lib/jsonapi/query_builder/base_sort.rb', line 10

def initialize(collection, direction = :asc)
  @collection = collection
  @direction = direction
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



6
7
8
# File 'lib/jsonapi/query_builder/base_sort.rb', line 6

def collection
  @collection
end

#directionObject (readonly)

Returns the value of attribute direction.



6
7
8
# File 'lib/jsonapi/query_builder/base_sort.rb', line 6

def direction
  @direction
end

Instance Method Details

#resultsActiveRecord::Relation

Returns Collection with order applied.

Returns:

  • (ActiveRecord::Relation)

    Collection with order applied

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/jsonapi/query_builder/base_sort.rb', line 16

def results
  raise NotImplementedError, "#{self.class} should implement #results"
end