Permalink
Browse files

Formatting...

  • Loading branch information...
1 parent 3696d54 commit 42016ac18d26e5237998c5748c51ada0d710fb46 @jnunemaker jnunemaker committed Apr 23, 2011
Showing with 5 additions and 8 deletions.
  1. +5 −8 lib/plucky/query.rb
View
@@ -40,14 +40,11 @@ def per_page(limit=nil)
end
def paginate(opts={})
- page = opts.delete(:page)
- limit = opts.delete(:per_page) || per_page
- query = clone.amend(opts)
- total = query.count
- paginator = Pagination::Paginator.new(total, page, limit)
- query[:limit] = paginator.limit
- query[:skip] = paginator.skip
- query.all.tap do |docs|
+ page = opts.delete(:page)
+ limit = opts.delete(:per_page) || per_page
+ query = clone.amend(opts)
+ paginator = Pagination::Paginator.new(query.count, page, limit)
+ query.amend(:limit => paginator.limit, :skip => paginator.skip).all.tap do |docs|
docs.extend(Pagination::Decorator)
docs.paginator(paginator)
end

0 comments on commit 42016ac

Please sign in to comment.