lib/gummi/repository/result.rb in gummi-0.1.0 vs lib/gummi/repository/result.rb in gummi-0.1.1
- old
+ new
@@ -1,19 +1,25 @@
module Gummi
module Repository
class Result
- attr_reader :took, :total, :hits, :facets
+ attr_reader :took, :total, :hits
def initialize(db_result, repository, per_page, page)
@took = db_result.took
@total = db_result.total
@hits = db_result.hits
@facets = db_result.facets
@db_records = db_result.records
@repository = repository
@per_page = per_page
@page = page
+ end
+
+ def facets
+ @facets.each_with_object({}) do |(name, content), facets|
+ facets[name] = Hash[content["terms"].collect{|term| term.values}]
+ end
end
def records
entities = Array(@repository.to_entity_from_db(@db_records)) if @db_records
Leaflet::Collection.new entities, page: @page, total: total, per_page: @per_page
\ No newline at end of file