dam5s/happymapper — pull request #26 by Confusion (2012-12-24 14:47:37+00:00)
Title: Support for default attribute values

(Sorry, I messed up https://github.com/dam5s/happymapper/pull/24 by pushing additional commits to this branch, which should be considered separately for inclusion. I force-pushed to remove them, but for some reason the commit in that pull request was also removed)

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.