Class: ActiveBlur::SearchResults
- Inherits:
-
Object
- Object
- ActiveBlur::SearchResults
- Includes:
- ActiveModel::Serialization
- Defined in:
- lib/active_blur/search_results.rb
Instance Attribute Summary collapse
-
#clazz ⇒ Object
Returns the value of attribute clazz.
-
#ids ⇒ Object
Returns the value of attribute ids.
-
#records ⇒ Object
Returns the value of attribute records.
-
#total_results ⇒ Object
Returns the value of attribute total_results.
Instance Method Summary collapse
-
#initialize(blur_results, clazz, should_fetch_records = false) ⇒ SearchResults
constructor
A new instance of SearchResults.
Constructor Details
#initialize(blur_results, clazz, should_fetch_records = false) ⇒ SearchResults
Returns a new instance of SearchResults.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/active_blur/search_results.rb', line 15 def initialize(blur_results, clazz, should_fetch_records=false) @total_results=blur_results.totalResults @clazz = clazz @ids=[] #@records=[] if fetch_records blur_results.results.each do |blur_result| score = blur_result.score fetch_result = blur_result.fetchResult if fetch_result && fetch_result.exists && !fetch_result.deleted && fetch_result.recordResult && fetch_result.recordResult.record record_id = fetch_result.recordResult.record.recordId @ids << ScoredResult.new(score, record_id) #@records << ScoredResult.new(score, clazz.find(record_id)) if fetch_records==true end end fetch_records if should_fetch_records end |
Instance Attribute Details
#clazz ⇒ Object
Returns the value of attribute clazz.
13 14 15 |
# File 'lib/active_blur/search_results.rb', line 13 def clazz @clazz end |
#ids ⇒ Object
Returns the value of attribute ids.
13 14 15 |
# File 'lib/active_blur/search_results.rb', line 13 def ids @ids end |
#records ⇒ Object
Returns the value of attribute records.
13 14 15 |
# File 'lib/active_blur/search_results.rb', line 13 def records @records end |
#total_results ⇒ Object
Returns the value of attribute total_results.
13 14 15 |
# File 'lib/active_blur/search_results.rb', line 13 def total_results @total_results end |