Sha256: bc403f12fbacbe84baf2264f3562efcf7a5f610058fa4b275aac9e397d210e52
Contents?: true
Size: 1.54 KB
Versions: 12
Compression:
Stored size: 1.54 KB
Contents
# frozen_string_literal: true require 'easy/jsonapi/request/query_param_collection' require 'easy/jsonapi/name_value_pair' require 'easy/jsonapi/exceptions/query_params_exceptions' require 'easy/jsonapi/utility' module JSONAPI class Request class QueryParamCollection < JSONAPI::NameValuePairCollection # A generic name=value query parameter class QueryParam < JSONAPI::NameValuePair # @param name [String] The name of the parameter # @param value [String | Array<String>] The value of the parameter 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 # Update the query_param value, turning value into an array if it was given as a string # @param new_value [String, Array<String>] The new value of the Parameter def value=(new_value) new_value = new_value.split(',') if new_value.is_a? String super(new_value) end # Represents a parameter as a string def to_s "#{name}=#{JSONAPI::Utility.to_string_collection(value, delimiter: ',')}" end # @raise RuntimeError Cannot change the name of a QueryParam object def name=(_) raise 'Cannot change the name of QueryParam Objects' end end end end end # include=author,comments-likers,comments.likes # author comments-likers comments.likes
Version data entries
12 entries across 12 versions & 1 rubygems