> “a.b.c”.to_hash(“Some value”)
5 6 7 8 9 10 11 12 13
# File 'lib/i18n_translation_spawner/string.rb', line 5 def to_hash(val=nil) keys = split('.') Hash.new.tap do |hsh| while k = keys.shift do hsh[k] = keys.empty? ? val : Hash.new hsh = hsh[k] end end end