On Oct 27, 8:10 pm, Nels Nelson <[email protected]> wrote: > Yes! Your guess is correct, and invoking marshallable! before to_yaml > works as you described. > > However, I suppose I will have to exclude a great many fields. Some > dumped fields seem redundant and irrelevant: > > associations: > :other: [] > > :chapters: > - !ruby/object:Chapter > new: false > values: > :id: 1 > :name: Introduction to Sequel > changed_columns: [] > > deserialized_values: > :glossary: > :something: Definition. > :another: This is important. > new: false > raise_on_save_failure: true > this: > values: > :id: 38 > :object_type: Book > :glossary: "--- \n\ > :something: Definition.\n\ > :another: This is important.\n" > > Or perhaps I just don't understand how YAML works. > > Also, when I attempt to load the YAML string, and get an object, I > encounter this error: > > NoMethodError: undefined method `has_key?' for nil:NilClass > /usr/java/jruby-1.6.5/lib/ruby/gems/1.8/gems/sequel-3.28.0/lib/sequel/ > plugins/serialization.rb:93:in `glossary' > org/yecht/ruby/Resolver.java:129:in `transfer'
The yaml loader is not recreating the @deserialized_values instance variable in the model instance. It should be a hash, but it's probably not set. > Not sure how to correct or work-around this. You probably just need to override the to_yaml instance method to the model that does what you want, and override whatever yaml's corressponding load method is. You may want to look at the xml_serializer and json_serializer plugins to see how they work, and do something similar for yaml. Why do you need to serialize entire model instances to xml, json, AND yaml, BTW? I noticed you are also serializing the glossary column to yaml. It's kind of amusing that you are serializing the objects on multiple levels. Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
