Sha256: f039fbf75985ce8a78493822194a2a15c89a6439e4ade70c2a1696504ec58459
Contents?: true
Size: 511 Bytes
Versions: 14
Compression:
Stored size: 511 Bytes
Contents
class String def normalize_attribute self.gsub(/^.*::/, ""). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). downcase end end class Hash def normalize h = {} self.each_pair do |k,v| attr = k.to_s.normalize_attribute case v when Hash h[attr] = v.normalize when Array h[attr] = v.map { |o| o.kind_of?(Hash) ? o.normalize : o } else h[attr] = v end end h end end
Version data entries
14 entries across 14 versions & 1 rubygems