Permalink
Browse files

Add Hash attributes coercon example to README

Issue #98
  • Loading branch information...
1 parent c4a9101 commit 47474edfe5bb47ba975a6df28fbaa4ac27e31a60 @greyblake greyblake committed Sep 2, 2012
Showing with 13 additions and 0 deletions.
  1. +13 −0 README.md
View
13 README.md
@@ -210,6 +210,19 @@ user.phone_numbers # => [#<PhoneNumber:0x007fdb2d3bef88 @number="212-555-1212">,
user.addresses # => #<Set: {#<Address:0x007fdb2d3be448 @address="1234 Any St.", @locality="Anytown", @region="DC", @postal_code="21234">}>
```
+### Hash attributes coercion
+
+``` ruby
+class Package
+ include Virtus
+
+ attribute :dimensions, Hash[Symbol => Float]
+end
+
+package = Package.new(:dimensions => { 'width' => "2.2", :height => 2, "length" => 4.5 })
+package.dimensions # => { :with => 2.2, :height => 2.0, :length => 4.5 }
+```
+
### Value Objects
``` ruby

0 comments on commit 47474ed

Please sign in to comment.