module Gummi module RepositoryLayer module Repository class Result attr_reader :took, :total, :hits def initialize(search_result, converter) @search_result = search_result @took = @search_result.took @documents = @search_result.documents @converter = converter end def facets return unless search_result.facets @facets ||= begin result = {} search_result.facets.each do |(name, content)| result[name] = Hash[content.terms.map(&:values)] end Hashie::Mash.new result end end def total documents.total_entries end def records @records ||= begin # Passing through the Leaflet Collection, but converting the records. documents.map! { |document| converter.db_instance_to_entity(document) } documents end end private attr_reader :search_result, :converter, :documents end end end end