Closed codesnik closed 9 years ago
This is a known issue. Maybe I should document it. /cc @elskwid
@solnic, I've labelled it for docs and assigned it to myself.
@codesnik This will address the correct class:
require 'virtus'
require 'mongoid'
class Foo
include Virtus.model
attribute :bar, Virtus::Attribute::Boolean
end
Foo.new(bar: 1).bar # => 1
@solnic I think that the documentation in the README, that was added when closing this PR, is actually wrong.
Here, @acook says to use the Virtus::Attribute::Boolean
class for explicitly specifying the Boolean
type but in the README there is Axiom::Types::Boolean
suggested. I believe that this causes problems that are described in this StackOverflow question, which seem to be fixed by using the Virtus::Attribute::Boolean
class indeed.
Can you confirm the correct form, please?
Sorry, I no longer maintain virtus.
This is a quite subtle problem. I'll try to illustrate:
Mongoid defines it's own ::Boolean class, and that was enough to silently break coercer.
This is probably a mongoid problem, it's quite dirty. But it raises a question if attribute type declaration magic is magic enough. Thoughts?