Sha256: 656e213e0ba19f72d69515c90fe29a34da3bb30a03d31f6854c344dd2105c7d4
Contents?: true
Size: 443 Bytes
Versions: 10
Compression:
Stored size: 443 Bytes
Contents
class Object def to_query(key) require 'cgi' unless defined?(CGI) && defined?(CGI::escape) "#{CGI.escape(key.to_s)}=#{CGI.escape(to_s)}" end end class Array def to_query(key) prefix = "#{key}[]" collect { |value| value.to_query(prefix) }.join '&' end end class Hash def to_query(namespace = nil) collect do |key, value| value.to_query(namespace ? "#{namespace}[#{key}]" : key) end.sort * '&' end end
Version data entries
10 entries across 10 versions & 1 rubygems