coercible icon indicating copy to clipboard operation
coercible copied to clipboard

Establish sane default for nil conversions

Open lovehandle opened this issue 10 years ago • 1 comments

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?

lovehandle avatar Aug 30 '13 10:08 lovehandle

Same for me. Nothing changed?

Jesterovskiy avatar Jul 31 '14 09:07 Jesterovskiy