lib/pagify/pager/data_mapper.rb in pagify-0.6.2 vs lib/pagify/pager/data_mapper.rb in pagify-0.7.0
- old
+ new
@@ -7,21 +7,30 @@
include PageAcceptStringOrBlank
attr_reader :model
def initialize model_class, opts = {}, query = {}
@model = model_class
- query ||= {}
query_opts = reject_pager_opts(opts)
super(opts.merge(
:fetcher => lambda{ |offset, per_page|
- model.send :with_scope, query do
+ # TODO: i am not sure why do we need this check?
+ if query == model.query
model.all(query_opts.merge(:offset => offset, :limit => per_page))
+ else
+ model.send(:with_scope, query) do
+ model.all(query_opts.merge(:offset => offset, :limit => per_page))
+ end
end
},
:counter => lambda{
- model.send :with_scope, query do
+ # TODO: i am not sure why do we need this check?
+ if query == model.query
model.count(query_opts)
+ else
+ model.send(:with_scope, query) do
+ model.count(query_opts)
+ end
end
}))
end
end # of DataMapperPager