Class: Restful::DeepHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/restful/serializer.rb

Overview

Provides some utility functions for acting deeply on hashes.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.deeply_stringify_keys!(object) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/restful/serializer.rb', line 94

def deeply_stringify_keys!(object)
  case object 
    when ::Hash 
      then
        object.stringify_keys!
        recurse_on = object.values
    when Array then recurse_on = object
  end
  recurse_on.each do |member|
    deeply_stringify_keys!(member)
  end if recurse_on
  return object 
end

Instance Method Details

#deeply_stringify_keys!Object

Walks the graph, and destructively applies stringify_keys!



110
111
112
# File 'lib/restful/serializer.rb', line 110

def deeply_stringify_keys!
  return DeepHash.deeply_stringify_keys!(self)
end