class Sunspot::NullResult::PaginatedNullArray

Implements the interface of github.com/sunspot/sunspot/blob/master/sunspot_rails/lib/sunspot/rails/stub_session_proxy.rb

Attributes

limit_value[R]
per_page[R]

Public Class Methods

new(collection, current_page: 1, per_page: 1, offset: nil) click to toggle source
Calls superclass method
# File lib/sunspot/null_result/paginated_null_array.rb, line 11
def initialize(collection, current_page: 1, per_page: 1, offset: nil)
  super(collection)
  @current_page = current_page.to_i
  @per_page     = per_page.to_i
  @offset       = offset
  @_collection  = collection
end

Public Instance Methods

current_page() click to toggle source
# File lib/sunspot/null_result/paginated_null_array.rb, line 39
def current_page
  if @_collection.respond_to?(:current_page)
    @_collection.current_page
  else
    @current_page
  end
end
first_page?() click to toggle source
# File lib/sunspot/null_result/paginated_null_array.rb, line 55
def first_page?
  true
end
last_page?() click to toggle source
# File lib/sunspot/null_result/paginated_null_array.rb, line 59
def last_page?
  true
end
next_page() click to toggle source
# File lib/sunspot/null_result/paginated_null_array.rb, line 51
def next_page
  (current_page+1) if total_pages > current_page
end
num_pages()
Alias for: total_pages
offset() click to toggle source
# File lib/sunspot/null_result/paginated_null_array.rb, line 67
def offset
  @offset || 0
end
out_of_bounds?() click to toggle source
# File lib/sunspot/null_result/paginated_null_array.rb, line 63
def out_of_bounds?
  false
end
prev_page() click to toggle source
# File lib/sunspot/null_result/paginated_null_array.rb, line 47
def prev_page
  (current_page-1) if current_page > 1
end
size() click to toggle source
Calls superclass method
# File lib/sunspot/null_result/paginated_null_array.rb, line 21
def size
  if @_collection.respond_to?(:total_count)
    @_collection.total_count
  else
    super
  end
end
Also aliased as: total_count
total_count()
Alias for: size
total_pages() click to toggle source
# File lib/sunspot/null_result/paginated_null_array.rb, line 30
def total_pages
  if @_collection.respond_to?(:total_pages)
    @_collection.total_pages
  else
    [(size/per_page.to_f).ceil, 1].max
  end
end
Also aliased as: num_pages