solnic/virtus — pull request #59 by emmanuel (2012-01-12 08:56:32+00:00)
Title: Collection member coercion

This is an initial implementation of support for collections with coercion to a member type. This works with EmbeddedValue member types, and should also work for simple/primitive member types (String, Integer, etc.).

Collection attributes with EmbeddedValue member types feels like the first step into something like relationships/associations in Virtus, so I imagine we'll want to think this through pretty well.

It looks like (from `examples/enumerable_types_spec.rb`):

```ruby
class PhoneNumber
include Virtus

attribute :number, String
end

class User
include Virtus

attribute :phone_numbers, Array[PhoneNumber]
end

user = User.new(:phone_numbers => [
{ :number => '212-555-1212' },
{ :number => '919-444-3265' },
])
user.phone_numbers # => [<#PhoneNumber...@number='212-555-1212'>, <#PhoneNumber...@number='919-444-3265'>]
```