Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-ext/hash.rb

Instance Method Summary collapse

Instance Method Details

#to_query_stringObject



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/ruby-ext/hash.rb', line 2

def to_query_string
  map { |k, v|
    if v.instance_of?(Hash)
      v.map { |sk, sv|
        "#{k}[#{sk}]=#{sv}"
      }.join('&')
    else
      "#{k}=#{v}"
    end
  }.join('&')
end