Sha256: 0afadf4d5ad243e8e94715db69b945a8b5fdb657f51c94b237d5776b6cfc05e3
Contents?: true
Size: 1.09 KB
Versions: 23
Compression:
Stored size: 1.09 KB
Contents
class Hash def to_http_str result = '' return result if self.empty? self.each do |key, val| result << "#{key}=#{URI.encode(val.to_s)}&" end result.chop end def symbolize_keys! self.each do |key, value| unless self.delete(key.to_s).nil? if value.is_a?(Hash) value.symbolize_keys! elsif value.is_a?(Array) value.map!{ |v| v.symbolize_keys! if v.is_a?(Hash) } end self[key.to_sym] = value end end self end def stringfy_keys! self.each do |key, value| unless self.delete(key.to_sym).nil? if value.is_a?(Hash) value.stringfy_keys! elsif value.is_a?(Array) value.map!{ |v| v.stringfy_keys! if v.is_a?(Hash) } end self[key.to_s] = value end end self end def stringfy_values! self.each do |key, value| if value.is_a?(Hash) value.stringfy_values! elsif value.is_a?(Array) value.map!{ |v| v.stringfy_values! if v.is_a?(Hash) } end self[key] = value.to_s end self end end
Version data entries
23 entries across 23 versions & 4 rubygems