Sha256: 3ed9d9f06b67230da458458785a4e51eb2dd86eea7013dd9e2808615a78fc9e0

Contents?: true

Size: 559 Bytes

Versions: 21

Compression:

Stored size: 559 Bytes

Contents

# frozen_string_literal: true
module  Drillbit
class   Parameters
class   Page
  PAGING_PARAMETERS     = %w{number size limit offset cursor}.freeze
  DEFAULT_STARTING_PAGE = 1
  DEFAULT_PAGE_SIZE     = 25

  attr_accessor :raw_parameters

  def initialize(raw_parameters)
    self.raw_parameters = raw_parameters || {}
  end

  def present?
    (raw_parameters.keys & PAGING_PARAMETERS).any?
  end

  def page_number
    raw_parameters['number'] || DEFAULT_STARTING_PAGE
  end

  def per_page
    raw_parameters['size'] || DEFAULT_PAGE_SIZE
  end
end
end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
drillbit-2.11.0 lib/drillbit/parameters/page.rb
drillbit-2.10.0 lib/drillbit/parameters/page.rb
drillbit-2.9.1 lib/drillbit/parameters/page.rb
drillbit-2.9.0 lib/drillbit/parameters/page.rb
drillbit-2.8.0 lib/drillbit/parameters/page.rb
drillbit-2.7.0 lib/drillbit/parameters/page.rb
drillbit-2.6.0 lib/drillbit/parameters/page.rb
drillbit-2.5.0 lib/drillbit/parameters/page.rb
drillbit-2.4.0 lib/drillbit/parameters/page.rb
drillbit-2.3.1 lib/drillbit/parameters/page.rb
drillbit-2.3.0 lib/drillbit/parameters/page.rb
drillbit-2.2.2 lib/drillbit/parameters/page.rb
drillbit-2.2.1 lib/drillbit/parameters/page.rb
drillbit-2.2.0 lib/drillbit/parameters/page.rb
drillbit-2.1.0 lib/drillbit/parameters/page.rb
drillbit-2.0.1 lib/drillbit/parameters/page.rb
drillbit-2.0.0 lib/drillbit/parameters/page.rb
drillbit-1.1.0 lib/drillbit/parameters/page.rb
drillbit-1.0.1 lib/drillbit/parameters/page.rb
drillbit-1.0.0 lib/drillbit/parameters/page.rb