tainbox icon indicating copy to clipboard operation
tainbox copied to clipboard

New boolean attribute syntax

Open wwwwhiterabbit opened this issue 5 years ago • 0 comments

class User
  attribute :admin?, default: false
end

person = User.new

person.admin? # => false
person.admin # => false

person.admin! # => #<User:0x00007fb0d45bb0f8 @tainbox_admin=true>
person.admin? # => true
person.admin # => true

person.attributes # => {:admin=>true}
person.as_json # => {"admin"=>true}

wwwwhiterabbit avatar Jun 10 '19 11:06 wwwwhiterabbit