Class: Supernova::Collection

Inherits:
WillPaginate::Collection
  • Object
show all
Defined in:
lib/supernova/collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#facetsObject

Returns the value of attribute facets.



4
5
6
# File 'lib/supernova/collection.rb', line 4

def facets
  @facets
end

#original_criteriaObject

Returns the value of attribute original_criteria.



4
5
6
# File 'lib/supernova/collection.rb', line 4

def original_criteria
  @original_criteria
end

#original_responseObject

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_queriesObject



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

#idsObject



25
26
27
# File 'lib/supernova/collection.rb', line 25

def ids
  @ids ||= extract_ids_from_solr_hash(original_response)
end

#original_facet_queriesObject



21
22
23
# File 'lib/supernova/collection.rb', line 21

def original_facet_queries
  original_criteria.search_options[:facet_queries] || {}
end

#raw_facet_countsObject



10
11
12
# File 'lib/supernova/collection.rb', line 10

def raw_facet_counts
  original_response["facet_counts"] || {}
end

#raw_facet_queriesObject



6
7
8
# File 'lib/supernova/collection.rb', line 6

def raw_facet_queries
  raw_facet_counts["facet_queries"] || {}
end