Class: Gummi::DbLayer::Document::Search::Result
- Inherits:
-
Object
- Object
- Gummi::DbLayer::Document::Search::Result
- Defined in:
- lib/gummi/db_layer/document/search/result.rb
Instance Attribute Summary collapse
-
#facets ⇒ Object
readonly
Returns the value of attribute facets.
-
#took ⇒ Object
readonly
Returns the value of attribute took.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
- #documents ⇒ Object
-
#initialize(response, converter, per_page, page) ⇒ Result
constructor
A new instance of Result.
- #success? ⇒ Boolean
Constructor Details
#initialize(response, converter, per_page, page) ⇒ Result
Returns a new instance of Result.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/gummi/db_layer/document/search/result.rb', line 9 def initialize(response, converter, per_page, page) @success = !!response @response = Hashie::Mash.new response @took = @response.took @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 |
Instance Attribute Details
#facets ⇒ Object (readonly)
Returns the value of attribute facets.
7 8 9 |
# File 'lib/gummi/db_layer/document/search/result.rb', line 7 def facets @facets end |
#took ⇒ Object (readonly)
Returns the value of attribute took.
7 8 9 |
# File 'lib/gummi/db_layer/document/search/result.rb', line 7 def took @took end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
7 8 9 |
# File 'lib/gummi/db_layer/document/search/result.rb', line 7 def total @total end |
Instance Method Details
#documents ⇒ Object
21 22 23 24 25 26 |
# File 'lib/gummi/db_layer/document/search/result.rb', line 21 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 |
#success? ⇒ Boolean
28 29 30 |
# File 'lib/gummi/db_layer/document/search/result.rb', line 28 def success? @success end |