solnic/virtus — pull request #275 by edgibbs (2014-07-04 18:06:06+00:00)
Title: Add handling of nil values for collection attributes

A recent upgrade from Virtus 0.5.5 to 1.0.2 exposed in issue that had changed with nil handling and collection attributes. We had code similar to this:

```ruby
atttribute :email_lists, Array[Integer]
```

This worked fine if the value was set to nil which was a reasonable value. After upgrading to 1.0.2 the unit tests where the value was set to nil blew up with the following error:

```
NoMethodError:
undefined method `each_with_object' for nil:NilClass
```

It looks like an explicit check was removed from the coerce() method on Collection class quite a while ago as part of a larger refactoring. This pull request fixes this issue with an explicit check. I'm not sure if this is the desired behavior for Virtus, but it makes it more usable for us.