Class: JSONAPI::Request::QueryParamCollection::QueryParam
- Inherits:
-
NameValuePair
- Object
- Item
- NameValuePair
- JSONAPI::Request::QueryParamCollection::QueryParam
- Defined in:
- lib/easy/jsonapi/request/query_param_collection/query_param.rb
Overview
A generic name=value query parameter
Direct Known Subclasses
FieldsParam, FilterParam, IncludeParam, PageParam, SortParam
Instance Attribute Summary
Attributes inherited from Item
Instance Method Summary collapse
-
#initialize(name, value) ⇒ QueryParam
constructor
A new instance of QueryParam.
- #name=(_) ⇒ Object
-
#to_s ⇒ Object
Represents a parameter as a string.
-
#value=(new_value) ⇒ Object
Update the query_param value, turning value into an array if it was given as a string.
Methods inherited from NameValuePair
Methods inherited from Item
Constructor Details
#initialize(name, value) ⇒ QueryParam
Returns a new instance of QueryParam.
17 18 19 20 21 22 23 |
# File 'lib/easy/jsonapi/request/query_param_collection/query_param.rb', line 17 def initialize(name, value) if instance_of?(QueryParam) JSONAPI::Exceptions::QueryParamsExceptions.check_param_name(name) end value = value.split(',') if value.is_a? String super(name, value) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class JSONAPI::Item
Instance Method Details
#name=(_) ⇒ Object
38 39 40 |
# File 'lib/easy/jsonapi/request/query_param_collection/query_param.rb', line 38 def name=(_) raise 'Cannot change the name of QueryParam Objects' end |
#to_s ⇒ Object
Represents a parameter as a string
33 34 35 |
# File 'lib/easy/jsonapi/request/query_param_collection/query_param.rb', line 33 def to_s "#{name}=#{JSONAPI::Utility.to_string_collection(value, delimiter: ',')}" end |
#value=(new_value) ⇒ Object
Update the query_param value, turning value into an array if it was given as a string
27 28 29 30 |
# File 'lib/easy/jsonapi/request/query_param_collection/query_param.rb', line 27 def value=(new_value) new_value = new_value.split(',') if new_value.is_a? String super(new_value) end |