mjijackson/symboltable — Issue #1: inheriting SymbolTable
Author: WhiteFire-Sondergaard
Created: 2012-01-20 04:07:42+00:00
State: open

There turns out to be a little problem with this class when you inherit it to make little tweaks to it. Specifically how it handles assigning hashes:

```ruby
irb(main):005:0> c.cont = { :TestVal2 => 2, :TestVal3 => 3 }
=> {:TestVal2=>2, :TestVal3=>3}
irb(main):006:0> c.cont.class
=> SymbolTable
irb(main):007:0> c.class
=> XATS::Configuration
```

As you can see, this creates a SymbolTable rather than the new class.

To fix this, you can use self.class rather than hardcoding SymbolTable to make the code more inherit friendly:

```ruby
# Sets the value of the given +key+ to +val+.
def store(key, val)
if valid_key?(key)
val = self.class.new(val) if Hash === val && !(self.class === val)
super(key.to_sym, val)
end
end
```