solnic / virtus

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

Strict mode doesn't report which attribute coercion failed #270

Closed dredozubov closed 10 years ago

dredozubov commented 10 years ago
class Committer
  include Virtus.model(strict: true)
  attribute :nickname, String
  attribute :karma, Integer
end

Committer.new(nickname: 'dredozubov', karma: nil)

we get

Virtus::CoercionError: Failed to coerce nil into Integer
from /Users/dr/.gem/ruby/2.1.0/gems/virtus-1.0.2/lib/virtus/attribute/strict.rb:19:in `coerce'

It seems pretty useless to me. Output like this will be much more helpful:

Virtus::CoercionError: Failed to coerce nil into Integer on attribute 'karma'
from /Users/dr/.gem/ruby/2.1.0/gems/virtus-1.0.2/lib/virtus/attribute/strict.rb:19:in `coerce'

Any thoughts and/or counter-examples?

solnic commented 10 years ago

This was improved via this commit

dredozubov commented 10 years ago

:+1: any chance of bumping virtus to 1.0.3 with recent changes?

solnic commented 10 years ago

@dredozubov sure, I'll push a new version next Friday

dredozubov commented 10 years ago

@solnic thanks!

solnic commented 10 years ago

@dredozubov sorry, I got sick last week and didn't manage to work on OSS :( I'll catch up this week.

dredozubov commented 10 years ago

@solnic no problem, get well and keep up the good work!