class JSONAPI::Request::QueryParamCollection::PageParam

Used to create a unique Page JSONAPI::Request::QueryParamCollection::QueryParam

Public Class Methods

new(offset:, limit:) click to toggle source

@param offset [Integer | String] the page offset @param limit [Integer | String] the # of resources returned on a given page

Calls superclass method
# File lib/easy/jsonapi/request/query_param_collection/page_param.rb, line 13
def initialize(offset:, limit:)
  super('page', { offset: offset.to_i, limit: limit.to_i })
end

Public Instance Methods

limit() click to toggle source

@return [Integer] The # of resources returned on a given page

# File lib/easy/jsonapi/request/query_param_collection/page_param.rb, line 38
def limit
  @item[:value][:limit]
end
limit=(new_limit) click to toggle source

@param new_limit [Integer] The new page limit number

# File lib/easy/jsonapi/request/query_param_collection/page_param.rb, line 43
def limit=(new_limit)
  @item[:value][:limit] = new_limit.to_i
end
offset() click to toggle source

@return [Integer] The page offset

# File lib/easy/jsonapi/request/query_param_collection/page_param.rb, line 28
def offset
  @item[:value][:offset]
end
offset=(new_offset) click to toggle source

@param new_offset [Integer | String] The new page offset number

# File lib/easy/jsonapi/request/query_param_collection/page_param.rb, line 33
def offset=(new_offset)
  @item[:value][:offset] = new_offset.to_i
end
to_s() click to toggle source

Represents the Page class in a string format

# File lib/easy/jsonapi/request/query_param_collection/page_param.rb, line 48
def to_s
  "page[offset]=#{offset}&page[limit]=#{limit}"
end
value() click to toggle source

@raise [RuntimeError] Informs user to use a different method

# File lib/easy/jsonapi/request/query_param_collection/page_param.rb, line 18
def value
  raise 'PageParam does not provide a #value method, try #offset or #limit instead'
end
value=(_) click to toggle source

@raise [RuntimeError] Informs user to use a different method

# File lib/easy/jsonapi/request/query_param_collection/page_param.rb, line 23
def value=(_)
  raise 'PageParam does not provide a #value= method, try #offset= or #limit= instead'
end