Class: JSONAPI::Request::QueryParamCollection::PageParam
- Inherits:
-
QueryParam
show all
- 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
#item
Instance Method Summary
collapse
Methods inherited from QueryParam
#name=
#name, #name=, #to_h
Methods inherited from Item
#to_h
Constructor Details
#initialize(offset:, limit:) ⇒ 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
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
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
|