lib/restpack_serializer/serializable/paging.rb in restpack_serializer-0.4.11 vs lib/restpack_serializer/serializable/paging.rb in restpack_serializer-0.4.12

- old
+ new

@@ -1,21 +1,21 @@ module RestPack::Serializer::Paging extend ActiveSupport::Concern module ClassMethods - def page(params = {}, scope = nil) - page_with_options RestPack::Serializer::Options.new(self, params, scope) + 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 ) result = RestPack::Serializer::Result.new - result.resources[self.key] = serialize_page(page) + result.resources[self.key] = serialize_page(page, options) result.meta[self.key] = serialize_meta(page, options) if options.include_links result.links = self.links Array(RestPack::Serializer::Factory.create(*options.include)).each do |serializer| @@ -29,11 +29,11 @@ result.serialize end private - def serialize_page(page) - page.map { |model| self.as_json(model) } + def serialize_page(page, options) + page.map { |model| self.as_json(model, options.context) } end def serialize_meta(page, options) meta = { page: options.page,