solnic / virtus

[DISCONTINUED ] Attributes on Steroids for Plain Old Ruby Objects
MIT License
3.77k stars 229 forks source link

Inconsistent strict coercion behaviour #187

Closed skade closed 11 years ago

skade commented 11 years ago

Just leaving this as a note, it currently doesn't impact me a lot.

I am not sure whether this is a coercible or a virtus problem, but I see this behaviour in current master:

class Foo
  include Virtus

  attribute :date, Date
  attribute :float, Float
end

Foo.new(:date => "")
# => Coercible::UnsupportedCoercion...
Foo.new(:float => "") # or "134a", etc.
# =>  #<Foo:0x000001016d3240 @float="", @date=nil>

With strict coercion, I would expect the second example to fail with the same reason as the first.

solnic commented 11 years ago

Thanks that's a bug in coercible, it should raise. I'll be finishing the strict/non-strict coercions for virtus 1.0.0 final and fix this.

solnic commented 11 years ago

I'm gonna close this since it's actually a missing...feature, in coercible.