module Sequel::Plugins::BooleanReaders

The boolean_readers plugin allows for the creation of attribute? methods for boolean columns, which provides a nicer API. By default, the accessors are created for all columns of type :boolean. However, you can provide a block to the plugin to change the criteria used to determine if a column is boolean. The block is yielded with the column symbol for each column in the models dataset.

Usage:

# Add boolean attribute? methods for all columns of type :boolean
# in all model subclasses (called before loading subclasses)
Sequel::Model.plugin :boolean_readers

# Add boolean readers for all tinyint columns in the Album class
Album.plugin(:boolean_readers){|c| db_schema[c][:db_type] =~ /\Atinyint/}

# Add a boolean reader for a specific columns in the Artist class
Artist.plugin(:boolean_readers){|c| [:column1, :column2, :column3].include?(c)}