Class: Jsonapi::QueryBuilder::BaseFilter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection, query) ⇒ BaseFilter

Returns a new instance of BaseFilter.

Parameters:

  • collection (ActiveRecord::Relation)
  • query (String)

    the query value used for filtering



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

def initialize(collection, query)
  @collection = collection
  @query = query
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



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

def collection
  @collection
end

#queryObject (readonly)

Returns the value of attribute query.



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

def query
  @query
end

Instance Method Details

#resultsActiveRecord::Relation

Returns Collection with the filter applied.

Returns:

  • (ActiveRecord::Relation)

    Collection with the filter applied

Raises:

  • (NotImplementedError)


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

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