Module: ExtraLoop::Utils::URIAddition
- Defined in:
- lib/extraloop/utils.rb
Instance Method Summary collapse
-
#query_hash ⇒ Object
Public.
Instance Method Details
#query_hash ⇒ Object
Public
Generates a hash representation of a uri’s query string.
Returns a hash mapping the URL query parameters to their respective values
NOTE: this is intended as a decorator method for instances of URI::HTTP.
examples:
URI::parse(url).extend(URIAddition).query_hash
34 35 36 37 38 39 40 |
# File 'lib/extraloop/utils.rb', line 34 def query_hash return unless self.query self.query.split("&").reduce({}) do |memo, item| param, value = *item.split("=") memo.merge(param.to_sym => value) end end |