Method: Pagify::ActiveRecordPager#initialize
- Defined in:
- lib/pagify/pager/active_record.rb
#initialize(model_class, opts = {}) ⇒ ActiveRecordPager
Returns a new instance of ActiveRecordPager.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pagify/pager/active_record.rb', line 17 def initialize model_class, opts = {} @model = model_class query_opts = reject_pager_opts(opts) super(opts.merge( :fetcher => lambda{ |offset, per_page| model.find(:all, query_opts.merge(:offset => offset, :limit => per_page)) }, :counter => lambda{ model.count(query_opts) })) end |