Module: Forms::Config
- Defined in:
- lib/forms/config.rb
Class Method Summary collapse
Class Method Details
.convert(yaml) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/forms/config.rb', line 5 def convert(yaml) hash = hashify(yaml) hash = deep_symbolize_keys(hash) hash end |
.deep_symbolize_keys(item) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/forms/config.rb', line 16 def deep_symbolize_keys(item) case item when Hash item.inject({}) do |acc, (k, v)| acc[(k.to_sym rescue k)] = deep_symbolize_keys(v) acc end else item end end |
.hashify(yaml) ⇒ Object
12 13 14 |
# File 'lib/forms/config.rb', line 12 def hashify(yaml) YAML::load("--- !map:HashWithIndifferentAccess\n"+yaml) end |