Sha256: db554a3656c3030ade3447a06e449d3d5d96d84c0dc0e51184a81fa95f62f804
Contents?: true
Size: 953 Bytes
Versions: 4
Compression:
Stored size: 953 Bytes
Contents
# frozen_string_literal: true require 'drillbit/parameters/page' module Drillbit module Resource module Processors class Paging attr_accessor :resource, :parameters # rubocop:disable Style/OptionHash def initialize(resource, parameters = {}) self.resource = resource self.parameters = Parameters::Page.new(parameters['page'] || {}) end # rubocop:enable Style/OptionHash def self.processed(*attrs) new(*attrs).processed end def self.meta(*attrs) new(*attrs).meta end def processed return resource unless parameters.present? resource .page(parameters.page_number) .per(parameters.per_page) end def meta return {} unless parameters.present? { 'total-pages' => resource.total_pages, 'current-page' => resource.current_page, 'previous-page' => resource.prev_page, 'next-page' => resource.next_page, } end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems