Add MergeInitializer to Coercian example

Before:
```ruby
class Tweet < Hash
  include Hashie::Extensions::Coercion
  coerce_key :user, User
end

user_hash = { name: "Bob" }
Tweet.new(user: user_hash)
# => {}
```

After:
```ruby
class Tweet < Hash
  include Hashie::Extensions::Coercion
  include Hashie::Extensions::MergeInitializer
  coerce_key :user, User
end

user_hash = { name: "Bob" }
Tweet.new(user: user_hash)
#=> {:user=>#<struct User name={:name=>"Bob"}>}
```
This commit is contained in:
Paul Bowsher 2016-12-01 21:35:20 +00:00 committed by GitHub
parent e35e628ddd
commit faa728eb0b
1 changed files with 1 additions and 0 deletions

View File

@ -44,6 +44,7 @@ Coercions allow you to set up "coercion rules" based either on the key or the va
```ruby
class Tweet < Hash
include Hashie::Extensions::Coercion
include Hashie::Extensions::MergeInitializer
coerce_key :user, User
end