lib/mongo_adapter/adapter.rb in dm-mongo-adapter-0.2.0.pre1 vs lib/mongo_adapter/adapter.rb in dm-mongo-adapter-0.2.0.pre2
- old
+ new
@@ -152,11 +152,12 @@
model = record.model
model.properties.each do |property|
name = property.name
if model.public_method_defined?(name)
- value = record.__send__(name)
+ value = property.get(record)
+
attributes[property.field] = property.custom? ?
property.type.dump(value, property) : value
end
end
@@ -164,11 +165,11 @@
model.embedments.each do |name, embedment|
if model.public_method_defined?(name)
value = record.__send__(name)
if embedment.kind_of?(Embedments::OneToMany::Relationship)
- attributes[name] = value.map{ |resource| attributes_as_fields(resource) }
+ attributes[embedment.storage_name] = value.map{ |resource| attributes_as_fields(resource) }
else
attributes[name] = attributes_as_fields(value)
end
end
end
@@ -184,10 +185,10 @@
record.each do |key, value|
case key
when DataMapper::Property
attributes[key.field] = key.custom? ? key.type.dump(value, key) : value
when Embedments::Relationship
- attributes[key.name] = attributes_as_fields(value)
+ attributes[key.storage_name] = attributes_as_fields(value)
end
end
attributes
end