lib/restpack_serializer/serializable/paging.rb in restpack_serializer-0.5.2 vs lib/restpack_serializer/serializable/paging.rb in restpack_serializer-0.5.3

- old
+ new

@@ -33,21 +33,22 @@ page.map { |model| self.as_json(model, options.context) } end def serialize_meta(page, options) meta = { - page: options.page, - page_size: options.page_size, - count: page.total_count, - include: options.include + page: page.current_page, + page_size: page.limit_value, + count: page.total_count, + include: options.include, + page_count: page.total_pages, + previous_page: page.prev_page, + next_page: page.next_page } - 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[:first_href] = page_href(1, options) meta[:previous_href] = page_href(meta[:previous_page], options) meta[:next_href] = page_href(meta[:next_page], options) + meta[:last_href] = page_href(meta[:page_count], options) meta end def page_href(page, options) return nil unless page