Class: Net::HTTP::Post
- Inherits:
-
Object
- Object
- Net::HTTP::Post
- Defined in:
- lib/util.rb
Instance Method Summary collapse
-
#form_data=(params, sep = '&') ⇒ Object
handle multiple parameters with the same name.
- #param_line(k, v) ⇒ Object
Instance Method Details
#form_data=(params, sep = '&') ⇒ Object
handle multiple parameters with the same name
48 49 50 51 52 53 54 55 56 |
# File 'lib/util.rb', line 48 def form_data=(params, sep = '&') self.body = params.map {|key,value| if value.is_a?(Array) value.map{|v| param_line(key, v) } else param_line(key, value) end }.join(sep) end |
#param_line(k, v) ⇒ Object
58 59 60 |
# File 'lib/util.rb', line 58 def param_line(k, v) "#{urlencode(k.to_s)}=#{urlencode(v.to_s)}" end |