Class: Hash

Inherits:
Object show all
Defined in:
lib/restfully/extensions.rb

Direct Known Subclasses

Restfully::SpecialHash

Instance Method Summary collapse

Instance Method Details

#to_params(namespace = nil) ⇒ Object

Converts a hash into a string suitable for use as a URL query string. An optional namespace can be passed to enclose the param names. Taken from ActiveSupport



21
22
23
24
25
# File 'lib/restfully/extensions.rb', line 21

def to_params(namespace = nil)
  collect do |key, value|
    value.to_query(namespace ? "#{namespace}[#{key}]" : key)
  end * '&'
end