Class: JSONAPI::Request::QueryParamCollection::PageParam
- Inherits:
-
QueryParam
- Object
- Item
- NameValuePair
- QueryParam
- JSONAPI::Request::QueryParamCollection::PageParam
- Defined in:
- lib/easy/jsonapi/request/query_param_collection/page_param.rb
Overview
Used to create a unique Page JSONAPI::Request::QueryParamCollection::QueryParam
Instance Attribute Summary
Attributes inherited from Item
Instance Method Summary collapse
-
#initialize(offset:, limit:) ⇒ PageParam
constructor
A new instance of PageParam.
-
#limit ⇒ Integer
The # of resources returned on a given page.
- #limit=(new_limit) ⇒ Object
-
#offset ⇒ Integer
The page offset.
- #offset=(new_offset) ⇒ Object
-
#to_s ⇒ Object
Represents the Page class in a string format.
- #value ⇒ Object
- #value=(_) ⇒ Object
Methods inherited from QueryParam
Methods inherited from NameValuePair
Methods inherited from Item
Constructor Details
#initialize(offset:, limit:) ⇒ PageParam
Returns a new instance of PageParam.
13 14 15 |
# 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class JSONAPI::Item
Instance Method Details
#limit ⇒ Integer
Returns The # of resources returned on a given page.
38 39 40 |
# File 'lib/easy/jsonapi/request/query_param_collection/page_param.rb', line 38 def limit @item[:value][:limit] end |
#limit=(new_limit) ⇒ Object
43 44 45 |
# 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 ⇒ Integer
Returns The page offset.
28 29 30 |
# File 'lib/easy/jsonapi/request/query_param_collection/page_param.rb', line 28 def offset @item[:value][:offset] end |
#offset=(new_offset) ⇒ Object
33 34 35 |
# 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 ⇒ Object
Represents the Page class in a string format
48 49 50 |
# File 'lib/easy/jsonapi/request/query_param_collection/page_param.rb', line 48 def to_s "page[offset]=#{offset}&page[limit]=#{limit}" end |
#value ⇒ Object
18 19 20 |
# 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=(_) ⇒ Object
23 24 25 |
# 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 |