Module: Tins::HashSymbolizeKeysRecursive
- Extended by:
- ThreadLocal
- Defined in:
- lib/tins/hash_symbolize_keys_recursive.rb
Overview
This module provides recursive symbolization of hash keys. It handles nested structures including hashes and arrays, with special handling for circular references to prevent infinite recursion.
Instance Method Summary collapse
-
#symbolize_keys_recursive(circular: nil) ⇒ Hash, ...
Recursively converts all string keys in a hash (and nested hashes/arrays) to symbols.
-
#symbolize_keys_recursive!(circular: nil) ⇒ Hash, ...
Recursively converts all string keys in a hash (and nested hashes/arrays) to symbols.
Methods included from ThreadLocal
instance_thread_local, thread_local
Instance Method Details
#symbolize_keys_recursive(circular: nil) ⇒ Hash, ...
Recursively converts all string keys in a hash (and nested hashes/arrays) to symbols. This method does not modify the original hash.
50 51 52 53 54 55 |
# File 'lib/tins/hash_symbolize_keys_recursive.rb', line 50 def symbolize_keys_recursive(circular: nil) self.seen = {} _symbolize_keys_recursive(self, circular: circular) ensure self.seen = nil end |
#symbolize_keys_recursive!(circular: nil) ⇒ Hash, ...
Recursively converts all string keys in a hash (and nested hashes/arrays) to symbols. This method modifies the original hash in place.
69 70 71 |
# File 'lib/tins/hash_symbolize_keys_recursive.rb', line 69 def symbolize_keys_recursive!(circular: nil) replace symbolize_keys_recursive(circular: circular) end |