Sha256: 22c7fb999136d5496f0bf965db946dbc722debb55393ee71d121414a1560699f
Contents?: true
Size: 890 Bytes
Versions: 2
Compression:
Stored size: 890 Bytes
Contents
module Sunspot module Query # # 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. # class Pagination #:nodoc: attr_reader :page, :per_page def initialize(configuration, page = nil, per_page = nil) @configuration = configuration self.page, self.per_page = page, per_page end def to_params { :start => start, :rows => rows } end def page=(page) @page = (page || 1).to_i end def per_page=(per_page) @per_page = (per_page || @configuration.pagination.default_per_page).to_i end private def start (@page - 1) * @per_page end def rows @per_page end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
benjaminkrause-sunspot-0.9.7 | lib/sunspot/query/pagination.rb |
benjaminkrause-sunspot-0.9.8 | lib/sunspot/query/pagination.rb |