Sha256: 98fcebf28754675cfa06ef58c29046a872d3115b132f91ae08f83125495b3324
Contents?: true
Size: 876 Bytes
Versions: 17
Compression:
Stored size: 876 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 end def per_page=(per_page) @per_page = per_page || @configuration.pagination.default_per_page end private def start (@page - 1) * @per_page end def rows @per_page end end end end
Version data entries
17 entries across 17 versions & 6 rubygems