Skip to content

Instantly share code, notes, and snippets.

@sergii
Forked from gouthamvel/helper.rb
Last active August 29, 2015 14:08
Show Gist options
  • Save sergii/5d79b285a4cb4c9748ff to your computer and use it in GitHub Desktop.
Save sergii/5d79b285a4cb4c9748ff to your computer and use it in GitHub Desktop.
require 'active_support/core_ext/hash/keys'
class Hash
def recursively_symbolize_keys!
self.symbolize_keys!
self.values.each do |v|
if v.is_a? Hash
v.recursively_symbolize_keys!
elsif v.is_a? Array
v.recursively_symbolize_keys!
end
end
self
end
end
class Array
def recursively_symbolize_keys!
self.each do |item|
if item.is_a? Hash
item.recursively_symbolize_keys!
elsif item.is_a? Array
item.recursively_symbolize_keys!
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment