Module: MongoMapper::Plugins::Pagination::ClassMethods

Defined in:
lib/mongo_mapper/plugins/pagination.rb

Instance Method Summary collapse

Instance Method Details

#paginate(options) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/mongo_mapper/plugins/pagination.rb', line 9

def paginate(options)
  per_page      = options.delete(:per_page) || self.per_page
  page          = options.delete(:page)
  total_entries = count(options)
  pagination    = Pagination::PaginationProxy.new(total_entries, page, per_page)

  options.merge!(:limit => pagination.limit, :skip => pagination.skip)
  pagination.subject = find_many(options)
  pagination
end

#per_pageObject



5
6
7
# File 'lib/mongo_mapper/plugins/pagination.rb', line 5

def per_page
  25
end