Sha256: 5fb467a8dfd80cb056aea371c6684815daf1ad8a87535bf264ff5af1f168b7ce
Contents?: true
Size: 451 Bytes
Versions: 1
Compression:
Stored size: 451 Bytes
Contents
Hash.class_eval do def self.convert_keys(hash, method = :underscore) if hash.is_a?(Array) hash.collect {|h| convert_keys(h, method) } else hash_array = hash.collect do |key,value| value = value.is_a?(Hash) ? convert_keys(value, method) : value [ key.to_s.send(method), value ] end Hash[hash_array] end end def convert_keys(method = :underscore) Hash.convert_keys self, method end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hash-pipe-0.0.1 | lib/hash_pipe/key_conversion.rb |