-
Notifications
You must be signed in to change notification settings - Fork 177
Open
Description
For reference, the Product class in my ONIX library: http://github.com/yob/onix/blob/master/lib/onix/product.rb, lines 31-37.
The ONIX spec requires all dates to be formatted as YYYYMMDD.
I handle the to_xml conversion from a Date class to a string by defining a lambda method and passing it to the attribute using the :to_xml option.
For marshalling xml strings into Date objects, I was using ":as => Date", but that would raise an exception when I tried to parse a file that containing invalid dates ( like "00000000"). To define my own XML->Ruby process, I have to pass a block into the attribute definition. This works, but has lead to some duplication.
It would be awesome if I could pass a lambda object into :as, just like I can with :to_xml.
Metadata
Metadata
Assignees
Labels
No labels