Attribute_bitmask is a project mainly written in Ruby, based on the MIT license.
Treat an attribute as a bitmask
Attribute Bitmask is designed to allow you to create accessor methods to access bitmask fields as if they were boolean attributes in the model.
Simply declare an existing integer column as a bitmask with its possible values.
class User < ActiveRecord::Base bitmask :roles, :writer, :publisher, :editor, :proofreader end
You can then access the bitmask fields as if they were boolean columns.
user = User.create(:name => "Bruce", :publisher => true, :editor => true) user.publisher?
user.writer?
user.writer = true user.writer
user.writer?
user.roles
Copyright (c) 2010 [Robert Ferney], released under the MIT license