Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange Boolean behaviour #377

Open
ktimothy opened this issue Jun 13, 2017 · 5 comments
Open

Strange Boolean behaviour #377

ktimothy opened this issue Jun 13, 2017 · 5 comments

Comments

@ktimothy
Copy link

ktimothy commented Jun 13, 2017

irb(main):016:0> Virtus::Attribute.build(true).is_a?(Virtus::Attribute::Boolean)
=> true
irb(main):017:0> Virtus::Attribute.build(false).is_a?(Virtus::Attribute::Boolean)
=> false

Found it out while investigating a bug in grape.

@acook
Copy link

acook commented Jun 13, 2017

Yeah, looks like FalseClass isn't listed as a primitive for it: https://github.com/solnic/virtus/blob/master/lib/virtus/attribute/boolean.rb#L18

@ktimothy
Copy link
Author

It also looks like only one primitive type can be set.

(Oh, Ruby, TrueClass and FalseClass, seriously? =))

@envygeeks
Copy link
Contributor

Ruby has no primitive types.

@ktimothy
Copy link
Author

I meant primitive attribute of Virtus::Attribute class.

@acook
Copy link

acook commented Jun 14, 2017

@envygeeks Virtus::Attribute has a primitive accessor: https://github.com/solnic/virtus/blob/master/lib/virtus/attribute.rb#L51

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants