Skip to content

Commit

Permalink
addressable: Update overload signature of URI#query_values= (#722)
Browse files Browse the repository at this point in the history
Addressable::URI#query_values= additionally supports arguments given as
an Array of Arrays, where the values of the inner Arrays may be Strings
or Arrays of Strings.

For more information:
https://www.rubydoc.info/gems/addressable/Addressable/URI#query_values=-instance_method

Co-authored-by: Ross Kaffenberger <rosskaff@meraki.com>
  • Loading branch information
rossta and Ross Kaffenberger authored Nov 13, 2024
1 parent 9b07b7b commit 0c458c0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions gems/addressable/2.8/_test/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,20 @@
# "two" => "2",
# "fragment" => "foo"
# }

uri = Addressable::URI.parse(
"http://example.com/a/b/c"
)
uri.query_values # => nil
uri.query_values = {"one" => "1", "two" => "2"}
uri.query_values # => {"one" => "1", "two" => "2"}
uri.query_values = ["three", "four"]
uri.query_values # => {"three" => nil, "four" => nil}
uri.query_values = [["five", "5"], ["six", "6"]]
uri.query_values # => {"five" => "5", "six" => "6"}
uri.query_values = [["seven"], ["andup", ["8", "9", "10"]]]
uri.query_values # => {"seven"=> nil, "andup"=>"10"}
uri.query_values = [["seven", "7"], ["andup", ["8", "9", "10"]]]
uri.query_values # => {"seven"=>"7", "andup"=>"10"}
uri.query_values = nil
uri.query_values # => nil
1 change: 1 addition & 0 deletions gems/addressable/2.8/addressable.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ module Addressable
| (singleton(Array) return_type) -> Array[String]
def query_values=: (Hash[String, String]? new_query_values) -> Hash[String, String]?
| (Array[String] new_query_values) -> Array[String]
| (Array[[String | Array[String]]] new_query_values) -> Array[[String | Array[String]]]
def request_uri: () -> String
def request_uri=: (String new_request_uri) -> String
def fragment: () -> String?
Expand Down

0 comments on commit 0c458c0

Please sign in to comment.