Let's say I have a Virtus model User with a boolean attribute active:
class User
include Virtus.model
attribute :active, Boolean, default: false, lazy: true
end
Then I could user a helper method active?:
User.new.active? # => false
User.new(active: true).active? # => true
But when I try to extend from Virtus.model and define a boolean attribute on the fly:
class User; end
user = User.new
user.extend(Virtus.model)
user.attribute(:active, Axiom::Types::Boolean, default: false, lazy: true)
user.active = true
and use a helper method active? I get a NoMethodError kinda exception.
user.active? # => NoMethodError: undefined method `active?' for
Is there any possibility of using helper methods in this situation?