Class: Toller::Filter
- Inherits:
-
Object
- Object
- Toller::Filter
- Defined in:
- lib/toller/filter.rb
Overview
Filter
Instance Attribute Summary collapse
-
#parameter ⇒ Object
readonly
Returns the value of attribute parameter.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #apply!(collection, value) ⇒ Object
- #default ⇒ Object
-
#initialize(parameter, type, options) ⇒ Filter
constructor
A new instance of Filter.
Constructor Details
#initialize(parameter, type, options) ⇒ Filter
Returns a new instance of Filter.
10 11 12 13 14 15 16 17 18 |
# File 'lib/toller/filter.rb', line 10 def initialize(parameter, type, ) @parameter = parameter @type = type @properties = .reverse_merge( field: parameter, default: false, scope_name: nil ) end |
Instance Attribute Details
#parameter ⇒ Object (readonly)
Returns the value of attribute parameter.
8 9 10 |
# File 'lib/toller/filter.rb', line 8 def parameter @parameter end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
8 9 10 |
# File 'lib/toller/filter.rb', line 8 def properties @properties end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'lib/toller/filter.rb', line 8 def type @type end |
Instance Method Details
#apply!(collection, value) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/toller/filter.rb', line 20 def apply!(collection, value) if type == :scope Filters::ScopeHandler.new.call(collection, value, properties) else Filters::WhereHandler.new.call(collection, type, value, properties) end end |
#default ⇒ Object
28 29 30 |
# File 'lib/toller/filter.rb', line 28 def default properties[:default] end |