Skip to content

An extension to active record that allows use of enums in a database agnostic manner

Notifications You must be signed in to change notification settings

sideshowbandana/enumb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

enumb

enumb is a library that will allow the use of enums in a database agnostic fashion.

Download

gem install enumb

Defining Enum Columns

Each enum_column has a name and a set of attributes. The name is used to guess the class of the object by default, but it's possible to explicitly specify it:

  class User < ActiveRecord::Base
    enum_column :platform, [:iphone, :windows_mobile, :android]
    enum_column :state, [:on, :off, :waiting]
  end

Example

  @user = User.new
  @user.platform = :iphone
  @user.platform
=>:iphone
  @user[:platform]
=> 0 

About

An extension to active record that allows use of enums in a database agnostic manner

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages