Module: DeepSymbolizable

Defined in:
lib/deep_symbolize.rb

Overview

Symbolizes all of hash’s keys and subkeys. Also allows for custom pre-processing of keys (e.g. downcasing, etc) if the block is given:

somehash.deep_symbolize { |key| key.downcase }

Usage: either include it into global Hash class to make it available to

to all hashes, or extend only your own hash objects with this
module.
E.g.:
1) class Hash; include DeepSymbolizable; end
2) myhash.extend DeepSymbolizable

Defined Under Namespace

Modules: Symbolizers

Instance Method Summary collapse

Instance Method Details

#deep_symbolize(&block) ⇒ Object



15
16
17
18
19
# File 'lib/deep_symbolize.rb', line 15

def deep_symbolize(&block)
  method = self.class.to_s.downcase.to_sym
  syms = DeepSymbolizable::Symbolizers
  syms.respond_to?(method) ? syms.send(method, self, &block) : self
end