mbklein / confstruct

Yet another hash/struct-like configuration object for Ruby

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Configuration.new doesn't work with nested hashes

ineu opened this issue · comments

I'm trying to use Confstruct like

yaml = YAML.load_file 'application.yml'
config = Confstruct::Configuration.new yaml

When yaml contains nested hashes, it's not possible to reach inner members. But if i set inner member by hands, it works:

irb(main):001:0> require 'confstruct'
=> true
irb(main):002:0> x = {'a' => {'b' => 'c'}}
=> {"a"=>{"b"=>"c"}}
irb(main):003:0> config = Confstruct::Configuration.new x
=> {:a=>{"b"=>nil}}
irb(main):004:0> config[:a]['d'] = 'e'
=> "e"
irb(main):005:0> config
=> {:a=>{"b"=>nil, :d=>"e"}}

Thanks for finding this -- it seems to be an issue with stringified hash keys, which I didn't have a test for. I've just released v0.2.1 to address this.