lib/restpack_serializer/serializable/paging.rb in restpack_serializer-0.4.15 vs lib/restpack_serializer/serializable/paging.rb in restpack_serializer-0.4.16
- old
+ new
@@ -5,14 +5,11 @@
def page(params = {}, scope = nil, context = {})
page_with_options RestPack::Serializer::Options.new(self, params, scope, context)
end
def page_with_options(options)
- page = options.scope_with_filters.paginate(
- page: options.page,
- per_page: options.page_size
- )
+ page = options.scope_with_filters.page(options.page).per(options.page_size)
result = RestPack::Serializer::Result.new
result.resources[self.key] = serialize_page(page, options)
result.meta[self.key] = serialize_meta(page, options)
@@ -37,14 +34,14 @@
def serialize_meta(page, options)
meta = {
page: options.page,
page_size: options.page_size,
- count: page.total_entries,
+ count: page.total_count,
include: options.include
}
- meta[:page_count] = ((page.total_entries - 1) / options.page_size) + 1
+ meta[:page_count] = ((page.total_count - 1) / options.page_size) + 1
meta[:previous_page] = meta[:page] > 1 ? meta[:page] - 1 : nil
meta[:next_page] = meta[:page] < meta[:page_count] ? meta[:page] + 1 : nil
meta[:previous_href] = page_href(meta[:previous_page], options)
meta[:next_href] = page_href(meta[:next_page], options)