Closed MichaelXavier closed 10 years ago
You want this:
Virtus::Attribute.build(['Boolean']).coerce(['1', '0'])
...as it's shorter.
I do admit this is a bug because it should catch that member type is already an attribute sub-class and get primitive from that subclass.
I'll fix it shortly.
@MichaelXavier I just checked grape and its spec suite passes against latest virtus master :smile:
...I mean I had to update the way attribute instances are being built of course
Sweet! Did you just change it to do Virtus::Attributes.build(type)
instead of Virtus::Attributes.build(:a, type)
? I'm looking to put in a PR on the grape project that cases off of virtus version and constructs the attribute accordingly. I'll leave it to them to decide if that's the right approach.
@MichaelXavier yeah you need to just pass in the type...grape was one of the reasons why I did this btw
I've been working on some bugs I've found using virtus with grape. They coerce parameters using Virtus::Attribute.
So If I have a parameter that takes an array of booleans,
Virtus::Attributes.build([Virtus::Attributes::Boolean]).coerce(['1', '0']) returns ['1', '0']
Using a basic type like
[Float]
works fine. Using TrueClass/FalseClass works fine. Using Axiom::Types::Boolean work fine. There's something about Boolean that isn't working. Is grape doing something wrong or is this a bug?