Class: Sunspot::Query::Pagination

Inherits:
Object
  • Object
show all
Defined in:
lib/sunspot/query/pagination.rb

Overview

A query component that holds information about pagination. Unlike other query components, this one is mutable, because the query itself holds a reference to it and updates it if pagination is changed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page = nil, per_page = nil, offset = nil) ⇒ Pagination

Returns a new instance of Pagination.



11
12
13
# File 'lib/sunspot/query/pagination.rb', line 11

def initialize(page = nil, per_page = nil, offset = nil)
  self.offset, self.page, self.per_page = offset, page, per_page
end

Instance Attribute Details

#offsetObject

:nodoc:



9
10
11
# File 'lib/sunspot/query/pagination.rb', line 9

def offset
  @offset
end

#pageObject

:nodoc:



9
10
11
# File 'lib/sunspot/query/pagination.rb', line 9

def page
  @page
end

#per_pageObject

:nodoc:



9
10
11
# File 'lib/sunspot/query/pagination.rb', line 9

def per_page
  @per_page
end

Instance Method Details

#to_paramsObject



15
16
17
# File 'lib/sunspot/query/pagination.rb', line 15

def to_params
  { :start => start, :rows => rows }
end