Module: WillPaginate::DataMapper::Pagination
- Defined in:
- lib/will_paginate/data_mapper.rb
Instance Method Summary collapse
Instance Method Details
#page(num) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/will_paginate/data_mapper.rb', line 10 def page(num) pagenum = ::WillPaginate::PageNumber(num.nil? ? 1 : num) per_page = query.limit || self.per_page = {:offset => pagenum.to_offset(per_page).to_i} [:limit] = per_page unless query.limit col = new_collection(query.merge()) col.current_page = pagenum col end |
#paginate(options) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/will_paginate/data_mapper.rb', line 20 def paginate() = .dup pagenum = .fetch(:page) { raise ArgumentError, ":page parameter required" } per_page = .delete(:per_page) || self.per_page .delete(:page) [:limit] = per_page.to_i all().page(pagenum) end |