dam5s/happymapper — pull request #24 by Confusion (2012-12-04 16:35:15+00:00)
Title: Support for default attribute values

I've added support for a `:default` option to `attribute` declarations. This makes it easy to declare default values, without requiring you to write `initialize` functions that set them. When working with an XML schema, these `:default` values can nicely reflect the 'default' declarations in the XSD.

Our use case is we generate classes that `include HappyMapper` from information parsed from an XSD. With this extension we can easily add a `:default => 'some_value'` to the generated `attribute :foo, String` lines, based on the default declarations parsed from the XSD. However, it seems like something that may more generally be considered useful.