Class: Filterameter::Filters::AttributeFilter
- Inherits:
-
Object
- Object
- Filterameter::Filters::AttributeFilter
- 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
Instance Method Summary collapse
- #apply(query, value) ⇒ Object
-
#initialize(attribute_name) ⇒ AttributeFilter
constructor
A new instance of AttributeFilter.
Methods included from Errors
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 |