openid/ruby-openid — pull request #58 by tobiashm (2013-09-12 07:27:10+00:00)
Title: Be aware when using Hash or Array as default value for unknown Hash keys

If you're using `Hash.new([])` or `Hash#default=` then it's the same object that is assigned to each unknown key, so you'll be adding to the same array when e.g. adding multiple AX attributes.

```
m = OpenID::AX::KeyValueMessage.new
m.add_value("a", "foo") # => ["foo"]
m.add_value("b", "bar") # => ["foo", "bar"]
m["a"] # => ["foo", "bar"]
```

By using a block to specify the default value, we get a new Array/Hash for each unknown key.

See also http://www.ruby-doc.org/core-2.0.0/Hash.html#new-method (same for all versions)