Sha256: dffa872ba68da25da5954ccbb2f74fd54f8d878bf90b65b05ddb919b3c2bc334
Contents?: true
Size: 646 Bytes
Versions: 2
Compression:
Stored size: 646 Bytes
Contents
class Hash #returns a string of post parameters for http posts, url-encoded def to_post_parameters params = "" self.each do |k, v| params += "&" unless params.empty? params += "#{k}=#{HttpUtility.url_encode(v.to_s.to_clr_string)}" end params end def to_s res = self.collect do |k, v| val = case when v.is_a?(String) "\"#{v}\"" when v.is_a?(Symbol) ":#{v}" else "#{v}" end "#{k.is_a?(Symbol) ? ":#{k}" : "#{k}" } => #{val}" end "{ #{res.join(', ')} }" end alias_method :to_str, :to_s alias_method :inspect, :to_s end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ironnails-0.0.3 | lib/ironnails/core_ext/hash.rb |
ironnails-0.0.1 | lib/ironnails/core_ext/hash.rb |