title: What is this Hash-like/Tree-like Construct Called?
body: <p>I want to create a "Config" class that acts somewhere between a hash and a tree.  It's just for storing global values, which can have a context.</p>
  
  <p>Here's how I use it:</p>
  
  <pre><code>Config.get("root.parent.child_b") #=&gt; "value"
  </code></pre>
  
  <p>Here's what the class might look like:</p>
  
  <pre><code>class Construct
  
    def get(path)
      # split path by "."
      # search tree for nodes
    end
  
    def set(key, value)
      # split path by "."
      # create tree node if necessary
      # set tree value
    end
  
    def tree
      {
        :root =&gt; {
          :parent =&gt; {
            :child_a =&gt; "value",
            :child_b =&gt; "another value"
          },
          :another_parent =&gt; {
            :something =&gt; {
              :nesting =&gt; "goes on and on"
            }
          }
        }
      }
    end
  
  end
  </code></pre>
  
  <p>Is there a name for this kind of thing, somewhere between Hash and Tree (not a Computer Science major)?  Basically a hash-like interface to a tree.</p>
  
  <p>Something that outputs like this:</p>
  
  <pre><code>t = TreeHash.new
  t.set("root.parent.child_a", "value")
  t.set("root.parent.child_b", "another value")
  </code></pre>
  
  <p>desired output format:</p>
  
  <pre><code>t.get("root.parent.child_a") #=&gt; "value"
  t.get("root") #=&gt; {"parent" =&gt; {"child_a" =&gt; "value", "child_b" =&gt; "another value"}}
  </code></pre>
  
  <p>instead of this:</p>
  
  <pre><code>t.get("root") #=&gt; nil
  </code></pre>
  
  <p>or this (which you get the value from by calling <code>{}.value</code>)</p>
  
  <pre><code>t.get("root") #=&gt; {"parent" =&gt; {"child_a" =&gt; {}, "child_b" =&gt; {}}}
  </code></pre>