Sha256: 34dc6b308e605998720b38dbf29389f53ae020fcd6e9f6d05d6f92555b0999dc
Contents?: true
Size: 648 Bytes
Versions: 6
Compression:
Stored size: 648 Bytes
Contents
class String def underscore self.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end end class Hash # FROM: File activesupport/lib/active_support/core_ext/hash/keys.rb, line 50 # made recursive by JB def recursive_symbolize_keys! recursive_transform_keys!{ |key| key.to_sym rescue key } end def recursive_transform_keys! return enum_for(:transform_keys!) unless block_given? keys.each do |key| value = delete(key) self[yield(key)] = value.kind_of?(Hash) ? value.recursive_symbolize_keys! : value end self end end
Version data entries
6 entries across 6 versions & 1 rubygems