README.md in virtus-1.0.0.beta7 vs README.md in virtus-1.0.0.beta8
- old
+ new
@@ -474,10 +474,13 @@
attribute :name, String, :coercer => my_cool_coercer
end
```
+Please check out [Coercible README](https://github.com/solnic/coercible/blob/master/README.md)
+for more information.
+
## Strict Coercion Mode
By default Virtus returns the input value even when it couldn't coerce it to the expected type.
If you want to catch such cases in a noisy way you can use the strict mode in which
Virtus raises an exception when it failed to coerce an input value.
@@ -517,11 +520,37 @@
attribute :name, String
attribute :admin, Boolean
end
```
-Please check out [Coercible README](https://github.com/solnic/coercible/blob/master/README.md)
-for more information.
+## Attribute Finalization and Circular Dependencies
+
+If a type references another type which happens to not be available yet you need
+to use lazy-finalization of attributes and finalize virtus manually after all
+types have been already loaded:
+
+``` ruby
+# in blog.rb
+class Blog
+ include Virtus.model(:finalize => false)
+
+ attribute :posts, Array['Post']
+end
+
+# in post.rb
+class Post
+ include Virtus.model(:finalize => false)
+
+ attribute :blog, 'Blog'
+end
+
+# after loading both files just do:
+Virtus.finalize
+
+# constants will be resolved:
+Blog.attribute_set[:posts].member_type.primitive # => Post
+Post.attribute_set[:blog].type.primitive # => Blog
+```
Credits
-------
* Dan Kubb ([dkubb](https://github.com/dkubb))