Class: ElasticQueue::Results

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_queue/results.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(queue, search_results, query_options) ⇒ Results

Returns a new instance of Results.



9
10
11
12
13
14
15
16
17
18
# File 'lib/elastic_queue/results.rb', line 9

def initialize(queue, search_results, query_options)
  @queue = queue
  @instantiated_queue_items = instantiate_queue_items(search_results)
  @start = query_options.page
  @per_page = query_options.per_page
  @total = search_results[:hits][:total]
  @paginate = WillPaginate::Collection.create(@start, @per_page, @total) do |pager|
    pager.replace(@instantiated_queue_items)
  end
end

Instance Attribute Details

#paginateObject (readonly)

Returns the value of attribute paginate.



5
6
7
# File 'lib/elastic_queue/results.rb', line 5

def paginate
  @paginate
end

Instance Method Details

#instantiate_queue_items(search_results) ⇒ Object



20
21
22
23
24
# File 'lib/elastic_queue/results.rb', line 20

def instantiate_queue_items(search_results)
  grouped_results, sort_order = group_sorted_results(search_results)
  records = fetch_records(grouped_results)
  sort_records(records, sort_order)
end