Skip to content

sachuisaac/sequel_enum

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sequel_enum

A Sequel plugin that provides enum-like functionality to your models.

Installation

Add this line to your application's Gemfile:

gem 'sequel_enum'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sequel_enum

Usage

class Item < Sequel::Model
  plugin :enum
  enum :condition, [:mint, :good, :poor]
end

item = Item.new
item.condition = :mint

item.condition #> :mint
item.mint? #> true
item.good? #> false

#enum accepts a hash like { index => value } as well:

class Item < Sequel::Model
  plugin :enum
  enum :condition, {10 => :mint, 11 => :good, 15 => :poor}
end

item = Item.new
item.condition = :mint

item[:condition] #> 10

Contributing

  1. Fork it ( http://github.com/planas/sequel_enum/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

Enum-like functionality for your Sequel models

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Ruby 100.0%