Module: DataMapper::Is::Paginated::ClassMethods
- Defined in:
- lib/dm-is-page-by-page/is/paginated.rb
Instance Method Summary collapse
Instance Method Details
#paginated(options = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dm-is-page-by-page/is/paginated.rb', line 11 def paginated( = {}) page = .delete(:page) || 1 per_page = .delete(:per_page) || 5 .reverse_merge!({ :order => [:id.desc] }) page_count = (count().to_f / per_page).ceil .merge!({ :limit => per_page, :offset => (page - 1) * per_page }) [ page_count , all() ] end |