Class: Gummi::Repository::Result
- Inherits:
-
Object
- Object
- Gummi::Repository::Result
- Defined in:
- lib/gummi/repository/result.rb
Instance Attribute Summary collapse
-
#hits ⇒ Object
readonly
Returns the value of attribute hits.
-
#took ⇒ Object
readonly
Returns the value of attribute took.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
- #facets ⇒ Object
-
#initialize(db_result, repository, per_page, page) ⇒ Result
constructor
A new instance of Result.
- #records ⇒ Object
Constructor Details
#initialize(db_result, repository, per_page, page) ⇒ Result
Returns a new instance of Result.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/gummi/repository/result.rb', line 7 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 |
Instance Attribute Details
#hits ⇒ Object (readonly)
Returns the value of attribute hits.
5 6 7 |
# File 'lib/gummi/repository/result.rb', line 5 def hits @hits end |
#took ⇒ Object (readonly)
Returns the value of attribute took.
5 6 7 |
# File 'lib/gummi/repository/result.rb', line 5 def took @took end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
5 6 7 |
# File 'lib/gummi/repository/result.rb', line 5 def total @total end |
Instance Method Details
#facets ⇒ Object
18 19 20 21 22 |
# File 'lib/gummi/repository/result.rb', line 18 def facets @facets.each_with_object({}) do |(name, content), facets| facets[name] = Hash[content["terms"].collect{|term| term.values}] end end |
#records ⇒ Object
24 25 26 27 |
# File 'lib/gummi/repository/result.rb', line 24 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 end |