solnic / coercible

Powerful, flexible and configurable coercion library. And nothing more.
MIT License
137 stars 16 forks source link

Establish sane default for nil conversions #8

Open lovehandle opened 11 years ago

lovehandle commented 11 years ago

When I was in the process of porting Virtus over to RubyMotion, I noticed a peculiarity that I hadn't noticed in previous versions where one could no longer instantiate an object without passing in attributes as well.

E.G.

class User
  include Virtus
  attribute :name, String
end

User.new #=> UnsupportedCoercion: Object#to_string doesn't know how to coerce nil.

The issue arose with the addition of this line of code. The line previously looked like this.

I don't mind handling this one if you give me a strategy. Implement a NilClass coercer that returns value for every coercion method?

Jesterovskiy commented 10 years ago

Same for me. Nothing changed?