cast values through setters to ensure validations are run after mass assignment, for example

This commit is contained in:
Seth Ladd 2009-06-08 16:35:26 -10:00
parent 130fdd16dd
commit 209e36f61b

View file

@ -114,9 +114,13 @@ module CouchRest
if #{property.casted} && value.is_a?(Array)
arr = CastedArray.new
arr.casted_by = self
value.each { |v| arr << v }
value.each do |v|
obj = #{property.type}.new(v)
arr << obj
end
value = arr
elsif #{property.casted}
value = #{property.type}.new(v)
value.casted_by = self if value.respond_to?(:casted_by)
end
self['#{meth}'] = value