Method: Iri#add
- Defined in:
- lib/iri.rb
#add(hash) ⇒ Iri Also known as: with
Adds query parameters to the URI.
This method appends query parameters to existing ones. If a parameter with the same name already exists, both values will be present in the resulting URI.
You can ensure only one instance of a parameter by using del first:
141 142 143 144 145 146 147 148 149 150 |
# File 'lib/iri.rb', line 141 def add(hash) raise ArgumentError, "The hash can't be nil" if hash.nil? raise InvalidArguments unless hash.is_a?(Hash) modify_query do |params| hash.each do |k, v| params[k.to_s] = [] unless params[k.to_s] params[k.to_s] << v end end end |