Skip to content

#configure loses nested hashes somehow #14

Description

@jrochkind

This one is weird edge case of some kind, but i'm not sure what kind. Here's the reproduction:

conf = Confstruct::Configuration.new
conf.configure(    :top=>{:middle=>{"one"=>"two"}} )

conf.top.middle    # =>  {"one"=>"two"}
conf.top.middle.class # => Confstruct::HashWithStructAccess
conf.top.middle.one # => nil    WHAT?
conf.top.middle["one"]  # => nil  # uh?
conf.top.middle[:one]   #=> nil

What's going on? Is "one" somehow a reserved word too? Not sure. If we change the literal to a symbol, weirdly all is well. huh?

 conf = Confstruct::Configuration.new
 conf.configure(    :top=>{:middle=>{:one=>"two"}} )

 conf.top.middle.one  # => "two" # great!

Hmm, a string other than 'one'?

 conf = Confstruct::Configuration.new
 conf.configure(    :top=>{:middle=>{"foo"=>"two"}} )
 conf.top.middle # {"foo"=>"two"}
 conf.top.middle.foo  # => nil

Nope it's not the word 'one' I don't think.

But it doens't require three levels of nesting, one will do it with strings:

 conf = Confstruct::Configuration.new
 conf.configure("top" => { "bottom" => "bottom" })
 conf.top # => {"bottom" => "bottom" }
 conf.top.class #  => Confstruct::HashWithStructAccess
 conf.top.bottom # => nil
 conf.top["bottom"] #=> nil
 conf.top.keys # => ["bottom"]   WHAT???

Ugh. Any ideas?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions