Class: Slingshot::Results::Collection
- Inherits:
-
Object
- Object
- Slingshot::Results::Collection
- Includes:
- Enumerable
- Defined in:
- lib/slingshot/results/collection.rb
Instance Attribute Summary collapse
-
#facets ⇒ Object
readonly
Returns the value of attribute facets.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(response) ⇒ Collection
constructor
A new instance of Collection.
Constructor Details
#initialize(response) ⇒ Collection
Returns a new instance of Collection.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/slingshot/results/collection.rb', line 8 def initialize(response) @time = response['took'] @total = response['hits']['total'] @results = response['hits']['hits'].map do |h| if Configuration.wrapper == Hash h else document = h['_source'] ? h['_source'] : h['fields'] document['highlight'] = h['highlight'] if h['highlight'] h.update document if document Configuration.wrapper.new(h) end end @facets = response['facets'] end |
Instance Attribute Details
#facets ⇒ Object (readonly)
Returns the value of attribute facets.
6 7 8 |
# File 'lib/slingshot/results/collection.rb', line 6 def facets @facets end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
6 7 8 |
# File 'lib/slingshot/results/collection.rb', line 6 def results @results end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
6 7 8 |
# File 'lib/slingshot/results/collection.rb', line 6 def time @time end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
6 7 8 |
# File 'lib/slingshot/results/collection.rb', line 6 def total @total end |
Instance Method Details
#each(&block) ⇒ Object
24 25 26 |
# File 'lib/slingshot/results/collection.rb', line 24 def each(&block) @results.each(&block) end |