Class: RailsApiModel::Filters::BaseFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_api_model/filters/base_filter.rb

Direct Known Subclasses

Field

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_model, filter_key) ⇒ BaseFilter

Returns a new instance of BaseFilter.



6
7
8
9
# File 'lib/rails_api_model/filters/base_filter.rb', line 6

def initialize(api_model, filter_key)
  @api_model = api_model
  @filter_key = filter_key
end

Instance Attribute Details

#api_modelObject (readonly)

Returns the value of attribute api_model.



4
5
6
# File 'lib/rails_api_model/filters/base_filter.rb', line 4

def api_model
  @api_model
end

#filter_keyObject (readonly)

Returns the value of attribute filter_key.



4
5
6
# File 'lib/rails_api_model/filters/base_filter.rb', line 4

def filter_key
  @filter_key
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



15
16
17
18
# File 'lib/rails_api_model/filters/base_filter.rb', line 15

def ==(other)
  api_model  == other.api_model  &&
  filter_key == other.filter_key
end

#apply_scope(relation, key, value) ⇒ Object



11
12
13
# File 'lib/rails_api_model/filters/base_filter.rb', line 11

def apply_scope(relation, key, value)
  raise 'Not implemented in the base class'
end

#ar_modelObject



22
23
24
# File 'lib/rails_api_model/filters/base_filter.rb', line 22

def ar_model
  api_model.ar_model
end