module Gummi module DbLayer module Document module Search class Result attr_reader :took, :total, :hits, :facets def initialize(response, converter, per_page, page) @success = !!response @response = Hashie::Mash.new response @took = @response.hits.took if @response.hits @total = @response.hits.total if @response.hits @hits = @response.hits.hits if @response.hits @facets = @response.facets || Hashie::Mash.new @converter = converter @per_page = per_page @page = page end def documents @documents ||= begin documents = Array(converter.hits_to_documents(hits)) if hits Leaflet::Collection.new documents, total: total, page: page, per_page: per_page end end def success? @success end private attr_reader :response, :converter, :per_page, :page, :hits end end end end end