class Hash
Public Instance Methods
camelize(first_letter = :upper)
click to toggle source
# File lib/hash-tweaks.rb, line 11 def camelize(first_letter = :upper) dup.camelize!(first_letter) end
camelize!(first_letter = :upper)
click to toggle source
# File lib/hash-tweaks.rb, line 17 def camelize!(first_letter = :upper) keys.each do |key| # Check if key is symbol or string and if it is not CONSTANT_VARIABLE. if (Symbol === key || String === key) && !key.match?(/\A[A-Z_][A-Z_0-9]*\z/) new_key = (Symbol === key ? key.to_s : key).camelize(first_letter) self[Symbol === key ? new_key.to_sym : new_key] = self.delete(key) end end self end
deep_with_indifferent_access()
click to toggle source
# File lib/hash-tweaks.rb, line 30 def deep_with_indifferent_access each_with_object({}) do |(k, v), m| m[k] = v.respond_to?(:deep_with_indifferent_access) ? v.deep_with_indifferent_access : v end.with_indifferent_access end