Class: Hash

Inherits:
Object show all
Defined in:
lib/monkey.rb

Instance Method Summary collapse

Instance Method Details

#stringify_keysObject



45
46
47
48
49
50
# File 'lib/monkey.rb', line 45

def stringify_keys
  inject({}) do |options, (key, value)|
    options[key.to_s] = value
    options
  end
end

#stringify_keys!Object



54
55
56
# File 'lib/monkey.rb', line 54

def stringify_keys!
  self.replace(self.stringify_keys)
end

#symbolize_and_underscore_keysObject



75
76
77
78
79
80
# File 'lib/monkey.rb', line 75

def symbolize_and_underscore_keys
  inject({}) do |options, (key, value)|
    options[(key.to_s.underscore.to_sym rescue key) || key] = value
    options
  end
end

#symbolize_and_underscore_keys!Object



84
85
86
# File 'lib/monkey.rb', line 84

def symbolize_and_underscore_keys!
  self.replace(self.symbolize_and_underscore_keys)
end

#symbolize_keysObject



60
61
62
63
64
65
# File 'lib/monkey.rb', line 60

def symbolize_keys
  inject({}) do |options, (key, value)|
    options[(key.to_sym rescue key) || key] = value
    options
  end
end

#symbolize_keys!Object



69
70
71
# File 'lib/monkey.rb', line 69

def symbolize_keys!
  self.replace(self.symbolize_keys)
end