Sha256: ce897e99e1909a93b696993964fbdf56dc8de88b2306866333bea8fccaef96e9

Contents?: true

Size: 588 Bytes

Versions: 2

Compression:

Stored size: 588 Bytes

Contents

require "will_paginate"

class Supernova::Collection < WillPaginate::Collection
  attr_accessor :original_response, :facets, :original_criteria
  
  def raw_facet_queries
    raw_facet_counts["facet_queries"] || {}
  end
  
  def raw_facet_counts
    original_response["facet_counts"] || {}
  end
  
  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
  
  def original_facet_queries
    original_criteria.search_options[:facet_queries] || {}
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
supernova-0.7.3 lib/supernova/collection.rb
supernova-0.7.2 lib/supernova/collection.rb