Class: Supernova::Collection
- Inherits:
-
WillPaginate::Collection
- Object
- WillPaginate::Collection
- Supernova::Collection
- Defined in:
- lib/supernova/collection.rb
Instance Attribute Summary collapse
-
#facets ⇒ Object
Returns the value of attribute facets.
-
#original_criteria ⇒ Object
Returns the value of attribute original_criteria.
-
#original_response ⇒ Object
Returns the value of attribute original_response.
Instance Method Summary collapse
- #extract_ids_from_solr_hash(solr_hash) ⇒ Object
- #facet_queries ⇒ Object
- #ids ⇒ Object
- #original_facet_queries ⇒ Object
- #raw_facet_counts ⇒ Object
- #raw_facet_queries ⇒ Object
Instance Attribute Details
#facets ⇒ Object
Returns the value of attribute facets.
4 5 6 |
# File 'lib/supernova/collection.rb', line 4 def facets @facets end |
#original_criteria ⇒ Object
Returns the value of attribute original_criteria.
4 5 6 |
# File 'lib/supernova/collection.rb', line 4 def original_criteria @original_criteria end |
#original_response ⇒ Object
Returns the value of attribute original_response.
4 5 6 |
# File 'lib/supernova/collection.rb', line 4 def original_response @original_response end |
Instance Method Details
#extract_ids_from_solr_hash(solr_hash) ⇒ Object
29 30 31 32 33 |
# File 'lib/supernova/collection.rb', line 29 def extract_ids_from_solr_hash(solr_hash) col = self.dup col.replace(solr_hash["response"]["docs"].map { |hash| hash["id"][/(\d+)$/, 1].to_i }) col end |
#facet_queries ⇒ Object
14 15 16 17 18 19 |
# File 'lib/supernova/collection.rb', line 14 def facet_queries @facet_queries ||= raw_facet_queries.inject({}) do |hash, (raw_query, count)| hash[original_facet_queries.invert[raw_query]] = count hash end end |
#ids ⇒ Object
25 26 27 |
# File 'lib/supernova/collection.rb', line 25 def ids @ids ||= extract_ids_from_solr_hash(original_response) end |
#original_facet_queries ⇒ Object
21 22 23 |
# File 'lib/supernova/collection.rb', line 21 def original_facet_queries original_criteria.[:facet_queries] || {} end |
#raw_facet_counts ⇒ Object
10 11 12 |
# File 'lib/supernova/collection.rb', line 10 def raw_facet_counts original_response["facet_counts"] || {} end |
#raw_facet_queries ⇒ Object
6 7 8 |
# File 'lib/supernova/collection.rb', line 6 def raw_facet_queries raw_facet_counts["facet_queries"] || {} end |