solnic / virtus

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

Fixed attributes with Range type #261

Closed Hampei closed 9 years ago

Hampei commented 10 years ago

Range is an Enumerable, but not a "collection". It doesn't have an empty constructor and it doesn't have a '<'-operator.

This is sort of a quick-fix. I didn't write any tests, since that would only test the code, as there's no reason to expect a Range to be treated as a collection.

I believe a better solution would be to whitelist the likely classes and to add an option to make other classes be treated as a collection, with a clear description of how a collection for Vitus needs to quack. But that would not be backward compatible, so is something for 2.0.

solnic commented 9 years ago

I'm merging this in and I'll add a test and improve it a little bit. Thanks for catching this.