Class: FacetedSearch::Facets
- Inherits:
-
Object
- Object
- FacetedSearch::Facets
- Defined in:
- app/models/faceted_search/facets.rb
Defined Under Namespace
Classes: Checkboxes, Date, Default, DefaultList, FullTree, List, PrimitiveList, Text, Tree
Instance Attribute Summary collapse
-
#list ⇒ Object
readonly
Returns the value of attribute list.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize(params) ⇒ Facets
constructor
A new instance of Facets.
- #model_table_name ⇒ Object
- #path ⇒ Object
- #path_for(facet, value) ⇒ Object
- #results ⇒ Object
Constructor Details
#initialize(params) ⇒ Facets
Returns a new instance of Facets.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/models/faceted_search/facets.rb', line 5 def initialize(params) if params.is_a? ActionController::Parameters @params = params.to_unsafe_hash elsif params.is_a? Hash @params = params else @params = {} end @params = @params.symbolize_keys @list = [] end |
Instance Attribute Details
#list ⇒ Object (readonly)
Returns the value of attribute list.
3 4 5 |
# File 'app/models/faceted_search/facets.rb', line 3 def list @list end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
3 4 5 |
# File 'app/models/faceted_search/facets.rb', line 3 def model @model end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'app/models/faceted_search/facets.rb', line 3 def params @params end |
Instance Method Details
#model_table_name ⇒ Object
38 39 40 |
# File 'app/models/faceted_search/facets.rb', line 38 def model_table_name @model.table_name end |
#path ⇒ Object
17 18 19 |
# File 'app/models/faceted_search/facets.rb', line 17 def path '?facets' end |
#path_for(facet, value) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/models/faceted_search/facets.rb', line 21 def path_for(facet, value) p = path list.each do |current_facet| p += current_facet == facet ? current_facet.path_for(value) : current_facet.path end p end |
#results ⇒ Object
30 31 32 33 34 35 36 |
# File 'app/models/faceted_search/facets.rb', line 30 def results scope = @model list.each do |facet| scope = facet.add_scope(scope) end scope.distinct end |