Joon
12/21/2009 - 9:24 PM

hash to param

hash to param

require 'uri'
require 'yaml'

def hash_to_param(hash)
  params = []
  hash.each do |k,v|
    params << "#{URI.escape(k)}=#{URI.escape(v)}"
  end
  params.join("&")
end

def yaml_string_to_param(yaml)
  hash_to_param YAML.load(yaml)
end