Sha256: e016d9ebbe8374de80d983182e40473f416fd3695e08ac57ce9204d5fe89f4fc
Contents?: true
Size: 426 Bytes
Versions: 56
Compression:
Stored size: 426 Bytes
Contents
class Hash # Replace String keys in the current hash with symbol keys def keys_to_sym! new_hash = keys_to_sym self.clear new_hash.each do |k,v| self[k] = v end end def keys_to_sym symbolized_hash = {} self.each do |k,v| if k =~ /\A[a-zA-Z0-9!?_]+\Z/ symbolized_hash[k.to_sym] = v else symbolized_hash[k] = v end end symbolized_hash end end
Version data entries
56 entries across 56 versions & 2 rubygems