From: Sean O'Halpin Date: 2008-03-15T22:51:02+09:00 Subject: Re: ANN: doodle 0.0.1 On Fri, Mar 14, 2008 at 10:51 PM, Aman Gupta wrote: > Very cool. Any thoughts on serializing/persisting Doodle objects? > > Aman Gupta Well, you can serialize using YAML, e.g. using the example class definition from the original post: str = event.to_yaml loaded_event = YAML::load(str) However, this bypasses validation (because YAML::load works on the @instance_variable level rather than accessor level). I've just uploaded a newer version of doodle (0.0.4) that makes public the validate! method and adds a option all=true|false to force validation of all attributes. So you could load a dodgy YAML file and validate it like this: another_event = YAML::load(DATA.read) another_event.validate!(true) validate! will raise a Doodle::ValidationError if any validations are violated. (The exclamation mark denotes possible exception ahead.) I'm not entirely happy about this interface so it will probably change to just validate! in the next version (with no flag). The same method should work for any other low level loaders. The next phase of work on doodle will be to see how well I can integrate it with other libraries (like Sequel or Ambition for example). Regards, Sean