Module: URI

Defined in:
lib/bellows/http.rb

Class Method Summary collapse

Class Method Details

.encode_www_form(enum) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/bellows/http.rb', line 24

def self.encode_www_form(enum)
  enum.map do |k,v|
    if v.nil?
      k
    elsif v.respond_to?(:to_ary)
      v.to_ary.map do |w|
        str = k.dup
        unless w.nil?
          str << '='
          str << w
        end
      end.join('&')
    else
      str = k.dup
      str << '='
      str << v.to_s.gsub("%", "%25")
    end
  end.join('&')
end