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.



8
9
10
11
12
13
14
# File 'lib/elastic_queue/results.rb', line 8

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]
end

Instance Attribute Details

#instantiated_queue_itemsObject (readonly)

Returns the value of attribute instantiated_queue_items.



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

def instantiated_queue_items
  @instantiated_queue_items
end

Instance Method Details

#paginateObject



16
17
18
19
20
# File 'lib/elastic_queue/results.rb', line 16

def paginate
  WillPaginate::Collection.create(@start, @per_page, @total) do |pager|
    pager.replace(@instantiated_queue_items)
  end
end