solnic/virtus — pull request #67 by mbj (2012-02-13 12:35:14+00:00)
Title: Use EmbeddedValue#primitive instead of #model

The model attribute for EmbeddedValue had some kind of duplicated the
primitive lookup. Now OpenStruct is the default primitive for embedded
values, the user model still takes precedence.

This pull request removes EmbeddedValue#model and uses EmbeddedValue#primitive.

This is needed so I can use Aequitas Rule::PrimitiveType::Virtus. Aequitas uses EmbeddedValue#value_coerced?(value) internaly. Before this patch EmbeddedValue#primitive always returns ::Object, so value_ocerced?(value) always fails.

It would also be possible to simply override Attribute#value_coerced to not compare @primitive === value, and instead doing @model === value. But IMHO it is better to remove code than to add. My pull request uses the present "Primitive" infrastructure this is the way to go.

As a side note, since I needed to use OpenStruct as default primitive, I could remove the pending spec on Attribute.detect_type whith embedded values.

Feel free to comment, since this is my first contribution to virtus it is likely I missed some important points.