README.md in virtus-1.0.0.beta8 vs README.md in virtus-1.0.0.rc1
- old
+ new
@@ -67,50 +67,40 @@
```
### Cherry-picking extensions
``` ruby
-# include just the attribute DSL
+# include attribute DSL + constructor + mass-assignment
class User
- include Virtus::Model::Core
+ include Virtus.model
attribute :name, String
end
-user = User.new
-user.name = 'Piotr'
+user = User.new(:name => 'Piotr')
+user.attributes = { :name => 'John' }
+user.attributes
+# => {:name => 'John'}
# include attribute DSL + constructor
class User
- include Virtus::Model::Core
- include Virtus::Model::Constructor
+ include Virtus.model(:mass_assignment => false)
attribute :name, String
end
User.new(:name => 'Piotr')
-# include attribute DSL + constructor + mass-assignment
+# include just the attribute DSL
class User
- include Virtus::Model::Core
- include Virtus::Model::Constructor
- include Virtus::Model::MassAssignment
+ include Virtus.model(:constructor => false, :mass_assignment => false)
attribute :name, String
end
-user = User.new(:name => 'Piotr')
-user.attributes = { :name => 'John' }
-user.attributes
-# => {:name => 'John'}
-
-# starting from virtus 1.0.0 preferred way to do this is to use module builder
-MyModel = Virtus.model(:constructor => false, :mass_assignment => false)
-
-class User
- include MyModel
-end
+user = User.new
+user.name = 'Piotr'
```
### Using Virtus with Modules
You can create modules extended with Virtus and define attributes for later
@@ -523,10 +513,10 @@
```
## 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
+to use lazy-finalization of attributes and finalize virtus manually after all
types have been already loaded:
``` ruby
# in blog.rb
class Blog