Anybody tried to save a collection of custom data types into a serialized 
attribute?

I've tried YAML.add_domain_type, but that didn't seem to do anything at all.

Then, in the Ruby PickAxe book, they talked about adding to_yaml_properties to 
your custom class, like this:

require 'yaml'

class ValuesOfConsumption
  attr_accessor :consumption, :start_date, :end_date
  
  def initialize(consumption, start_date, end_date)
    @consumption, @start_date, @end_date = consumption, start_date, end_date
  end
  
  def to_yaml_properties
    %w(@consumption @start_date @end_date)
  end
  
  def to_s
    "#...@consumption} #...@start_date} #...@end_date}"
  end
end

This works okay if I do YAML.dump and YAML.load, but doesn't seem to be called 
when I use a serialized attribute in ActiveRecord.

Anyone done anything like this?


-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" 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/rails-oceania?hl=en.

Reply via email to