| Class | WebMock::Util::QueryMapper |
| In: |
lib/webmock/util/query_mapper.rb
|
| Parent: | Object |
Converts the query component to a Hash value.
@option [Symbol] notation
May be one of <code>:flat</code>, <code>:dot</code>, or <code>:subscript</code>. The <code>:dot</code> notation is not supported for assignment. Default value is <code>:subscript</code>.
@return [Hash, Array] The query string parsed as a Hash or Array object.
@example
WebMock::Util::QueryMapper.query_to_values("?one=1&two=2&three=3")
#=> {"one" => "1", "two" => "2", "three" => "3"}
WebMock::Util::QueryMapper("?one[two][three]=four").query_values
#=> {"one" => {"two" => {"three" => "four"}}}
WebMock::Util::QueryMapper.query_to_values("?one.two.three=four",
:notation => :dot
)
#=> {"one" => {"two" => {"three" => "four"}}}
WebMock::Util::QueryMapper.query_to_values("?one[two][three]=four",
:notation => :flat
)
#=> {"one[two][three]" => "four"}
WebMock::Util::QueryMapper.query_to_values("?one.two.three=four",
:notation => :flat
)
#=> {"one.two.three" => "four"}
WebMock::Util::QueryMapper(
"?one[two][three][]=four&one[two][three][]=five"
)
#=> {"one" => {"two" => {"three" => ["four", "five"]}}}
WebMock::Util::QueryMapper.query_to_values(
"?one=two&one=three").query_values(:notation => :flat_array)
#=> [['one', 'two'], ['one', 'three']]
Sets the query component for this URI from a Hash object. This method produces a query string using the :subscript notation. An empty Hash will result in a nil query.
@param [Hash, to_hash, Array] new_query_values The new query values.