Class: Filterameter::Filters::AttributeFilter

Inherits:
Object
  • Object
show all
Includes:
Errors, AttributeValidator
Defined in:
lib/filterameter/filters/attribute_filter.rb

Overview

# Attribute Filter

Class AttributeFilter leverages ActiveRecord’s where query method to add criteria for an attribute.

Instance Attribute Summary

Attributes included from Errors

#errors

Instance Method Summary collapse

Methods included from Errors

#valid?

Constructor Details

#initialize(attribute_name) ⇒ AttributeFilter

Returns a new instance of AttributeFilter.



12
13
14
# File 'lib/filterameter/filters/attribute_filter.rb', line 12

def initialize(attribute_name)
  @attribute_name = attribute_name
end

Instance Method Details

#apply(query, value) ⇒ Object



16
17
18
# File 'lib/filterameter/filters/attribute_filter.rb', line 16

def apply(query, value)
  query.where(@attribute_name => value)
end