Class: Gum::Filter
- Inherits:
-
Object
- Object
- Gum::Filter
- Defined in:
- lib/gum/filter.rb
Direct Known Subclasses
Gum::Filters::Exists, Gum::Filters::Fuzzy, Gum::Filters::Geo::Bbox, Gum::Filters::Geo::Distance, Gum::Filters::Geo::Range, Gum::Filters::Prefix, Gum::Filters::Range, Gum::Filters::Regexp, Gum::Filters::Term, Gum::Filters::Terms, Gum::Filters::Wildcard, OrderBy
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#param ⇒ Object
readonly
Returns the value of attribute param.
Instance Method Summary collapse
- #__render__(value) ⇒ Object
- #empty?(params) ⇒ Boolean
-
#initialize(param, field, options) ⇒ Filter
constructor
A new instance of Filter.
- #render(params) ⇒ Object
- #value_from(params) ⇒ Object
Constructor Details
#initialize(param, field, options) ⇒ Filter
Returns a new instance of Filter.
5 6 7 8 9 |
# File 'lib/gum/filter.rb', line 5 def initialize(param, field, ) @param = param @field = field @options = || {} end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
3 4 5 |
# File 'lib/gum/filter.rb', line 3 def field @field end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/gum/filter.rb', line 3 def @options end |
#param ⇒ Object (readonly)
Returns the value of attribute param.
3 4 5 |
# File 'lib/gum/filter.rb', line 3 def param @param end |
Instance Method Details
#__render__(value) ⇒ Object
24 25 26 |
# File 'lib/gum/filter.rb', line 24 def __render__(value) raise NoMethodError end |
#empty?(params) ⇒ Boolean
20 21 22 |
# File 'lib/gum/filter.rb', line 20 def empty?(params) params[param].blank? end |
#render(params) ⇒ Object
11 12 13 14 |
# File 'lib/gum/filter.rb', line 11 def render(params) return if empty?(params) __render__ value_from(params) end |
#value_from(params) ⇒ Object
16 17 18 |
# File 'lib/gum/filter.rb', line 16 def value_from(params) params[param].presence end |