Skip to content

Commit

Permalink
Add Hash attributes coercon example to README
Browse files Browse the repository at this point in the history
Issue #98
  • Loading branch information
greyblake committed Sep 2, 2012
1 parent c4a9101 commit 47474ed
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Expand Up @@ -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
Expand Down

0 comments on commit 47474ed

Please sign in to comment.