Class: FortyFacets::Filter
- Inherits:
-
Struct
- Object
- Struct
- FortyFacets::Filter
- Defined in:
- lib/forty_facets/filter.rb
Overview
Base class for the objects representing a specific value for a specific type of filter. Most FilterDefinitions will have their own Filter subclass to control values for display and rendering to request parameters.
Direct Known Subclasses
CustomFilterDefinition::CustomFilter, FortyFacets::FacetFilterDefinition::FacetFilter, RangeFilterDefinition::RangeFilter, ScopeFilterDefinition::ScopeFilter, SqlFacetFilterDefinition::ScopeFacetFilter, TextFilterDefinition::TextFilter
Defined Under Namespace
Classes: FacetValue
Instance Attribute Summary collapse
-
#definition ⇒ Object
Returns the value of attribute definition.
-
#search_instance ⇒ Object
Returns the value of attribute search_instance.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #name ⇒ Object
-
#without ⇒ Object
generate a search with this filter removed.
Instance Attribute Details
#definition ⇒ Object
Returns the value of attribute definition
5 6 7 |
# File 'lib/forty_facets/filter.rb', line 5 def definition @definition end |
#search_instance ⇒ Object
Returns the value of attribute search_instance
5 6 7 |
# File 'lib/forty_facets/filter.rb', line 5 def search_instance @search_instance end |
#value ⇒ Object
Returns the value of attribute value
5 6 7 |
# File 'lib/forty_facets/filter.rb', line 5 def value @value end |
Instance Method Details
#empty? ⇒ Boolean
12 13 14 |
# File 'lib/forty_facets/filter.rb', line 12 def empty? value.nil? || value == '' || value == [] end |
#name ⇒ Object
8 9 10 |
# File 'lib/forty_facets/filter.rb', line 8 def name definition.[:name] || definition.path.join(' ') end |
#without ⇒ Object
generate a search with this filter removed
17 18 19 20 21 22 23 |
# File 'lib/forty_facets/filter.rb', line 17 def without search = search_instance return search if empty? new_params = search_instance.params || {} new_params.delete(definition.request_param) search_instance.class.new_unwrapped(new_params, search_instance.root) end |