Skip to content

Instantly share code, notes, and snippets.

@exAspArk
Last active August 29, 2015 14:02
Show Gist options
  • Save exAspArk/4aa5fa70acf5d492eda7 to your computer and use it in GitHub Desktop.
Save exAspArk/4aa5fa70acf5d492eda7 to your computer and use it in GitHub Desktop.
Nested symbolize keys (ruby)
def nested_symbolize_keys(thing)
case thing
when Array
thing.map { |value| nested_symbolize_keys(value) }
when Hash
Hash[thing.map { |key, value| [key.to_sym, nested_symbolize_keys(value)] }]
else
thing
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment