Predicate method for ActiveModel::Attributes boolean attributes

The ActiveModel::Attributes API allows us to define different types of attributes.

It handles type casting, default values, and defines read/write methods.

Typically when defining a boolean attribute, you will often define the respective predicate method.

For example:

class Person
  include ActiveModel::Attributes

  attribute :loves_rails, :boolean

  def loves_rails?
    !!loves_rails
  end
end

person = Person.new

person.loves_rails  # => nil
person.loves_rails? # => false

person.loves_rails = true

person.loves_rails? # => true

This proposal defines this predicate method automatically for all boolean attributes.

I did a little bit of digging, and came up with this initial solution, but it might not be an appropriate implementation.