Permalink
Browse files

Fix serialization and deserialization of datamapper objects.

  • Loading branch information...
1 parent cd0e15e commit 2235a44327a294e88792a64df41bfd652b8380ea @alexgb committed Jan 13, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/delayed/serialization/data_mapper.rb
@@ -5,15 +5,19 @@
def self.yaml_new(klass, tag, val)
begin
- klass.get!(val['attributes']['id'])
+ primary_keys = klass.properties.select { |p| p.key? }
+ key_names = primary_keys.map { |p| p.name.to_s }
+ klass.get!(*key_names.map { |k| val[k] })
rescue DataMapper::ObjectNotFoundError
raise Delayed::DeserializationError
end
end
def to_yaml_properties
- ['@attributes']
+ primary_keys = self.class.properties.select { |p| p.key? }
+ primary_keys.map { |p| "@#{p.name}" }
end
+
end
else
DataMapper::Resource.class_eval do

0 comments on commit 2235a44

Please sign in to comment.