Class: HashConverter
- Inherits:
-
Object
- Object
- HashConverter
- Defined in:
- lib/hash_converter.rb
Constant Summary collapse
- SEPARATOR =
"."
- KEY_REGEX =
/\{([^}]*)\}/
- Types =
[String, Integer, Float, Time, Date, DateTime]
Class Method Summary collapse
Class Method Details
.convert(hash = {}, &block) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/hash_converter.rb', line 12 def self.convert(hash = {}, &block) @hash = hash.namespace_flatten(SEPARATOR) @converted = {} @path = [] instance_eval(&block) @converted.namespace_unflatten.recursive_symbolize_keys! end |