Sha256: 9ed5ca07facb47cebdd2d4d6c5cf3ab1ea03f66a87f43531138c86a9011ba7f6
Contents?: true
Size: 828 Bytes
Versions: 19
Compression:
Stored size: 828 Bytes
Contents
class Hash def stringify_keys! keys.each do |key| self[key.to_s] = delete(key) end self end unless {}.respond_to?(:stringify_keys!) end class String def camelize dup.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } end unless "".respond_to?(:camelize) def constantize names = self.split('::') names.shift if names.empty? || names.first.empty? constant = Object names.each do |name| constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name) end constant end unless "".respond_to?(:constantize) def underscore dup.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end unless "".respond_to?(:underscore) end
Version data entries
19 entries across 19 versions & 1 rubygems