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

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

Instance Method Summary collapse

Instance Method Details

#paginate(options) ⇒ Object



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

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

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

#per_pageObject



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

def per_page
  25
end