Changed CastedModel so it does not cast nil values

This commit is contained in:
Eric Watson 2009-05-21 14:37:21 -05:00 committed by Matt Aimonetti
parent eb160e3141
commit 101024aabc

View file

@ -56,12 +56,8 @@ module CouchRest
else else
# Let people use :send as a Time parse arg # Let people use :send as a Time parse arg
klass = ::CouchRest.constantize(target) klass = ::CouchRest.constantize(target)
# I'm not convince we should or should not create a new instance if we are casting a doc/extended doc without default value and nothing was passed # Only cast this key if it has a value. Otherwise, leave nil.
# unless (property.casted && self[key].nil? ? nil : klass.send(property.init_method, self[key])
# (klass.superclass == CouchRest::ExtendedDocument || klass.superclass == CouchRest::Document) &&
# (self[key].nil? || property.default.nil?))
klass.send(property.init_method, self[key])
#end
end end
self[property.name].casted_by = self if self[property.name].respond_to?(:casted_by) self[property.name].casted_by = self if self[property.name].respond_to?(:casted_by)
end end