Module: MerbPaginate::Finders::Datamapper::ClassMethods
- Includes:
- GenericOrmMethods
- Defined in:
- lib/merb_paginate/finders/sequel.rb,
lib/merb_paginate/finders/datamapper.rb
Instance Method Summary collapse
-
#paginate(options = {}) ⇒ Object
This is the main paginating finder.
Instance Method Details
#paginate(options = {}) ⇒ Object
This is the main paginating finder.
Special parameters for paginating finders
- :page -- REQUIRED, but defaults to 1 if false or nil
- :per_page -- defaults to CurrentModel.per_page (which is 30 if not overridden)
- :total_entries -- use only if you manually count total entries
- :count -- additional options that are passed on to
count
All other options (+conditions+, order, ...) are forwarded to all
and count calls.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/merb_paginate/finders/datamapper.rb', line 29 def paginate( = {}) Merb.logger.info(" $$$ Sequel support in merb_paginate has not been tested at all. Please let me know if it works.") page, per_page, total_entries = () WillPaginate::Collection.create(page, per_page, total_entries) do |pager| = .except :page, :per_page, :total_entries = .except(:count).update(:offset => pager.offset, :limit => pager.per_page) pager.replace all() # magic counting for user convenience: pager.total_entries = wp_count() unless pager.total_entries end end |