Sha256: c8eb01e4e140ed5b584afee7170db726c5d316551df9410944a1bcdb9a4f1324
Contents?: true
Size: 783 Bytes
Versions: 3
Compression:
Stored size: 783 Bytes
Contents
#-- # Adapted from Gavin Sinclair's #convert_keys. #++ require 'facet/hash/keys_to_s%21' class Hash # Converts all keys in the Hash to be String values, returning a new Hash. # With a from_class parameter, limits conversion to only a certain class of keys. # It defaults to nil which convert any key class. # # require 'facet/hash/keys_to_s' # # foo = { :name=>'Gavin', :wife=>:Lisa } # foo.keys_to_s #=> { "name"=>"Gavin", "wife"=>:Lisa } # foo.inspect #=> { :name =>"Gavin", :wife=>:Lisa } # def keys_to_s( from_class=nil ) raise ArgumentError, "Parameter must be a class" unless from_class.kind_of?(Class) if from_class self.dup.keys_to_s!( from_class ) end # Deprecated name. #alias_method( :keys_to_string, :keys_to_s ) end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
facets-0.7.0 | lib/facet/hash/keys_to_s.rb |
facets-0.7.1 | lib/facet/hash/keys_to_s.rb |
facets-0.7.2 | lib/facet/hash/keys_to_s.rb |