A Sequel plugin that provides enum-like functionality to your models.
Add this line to your application's Gemfile:
gem 'sequel_enum'
And then execute:
$ bundle
Or install it yourself as:
$ gem install sequel_enum
classItem < Sequel::Modelplugin:enumenum:condition,[:mint,:good,:poor]enditem=Item.newitem.condition=:mintprintitem.condition#> :mintprintitem.mint?#> trueprintitem.good?#> falseitem.update(:condition=>:good)printitem.good?#> true#enum accepts a hash like { :alias => value } as well:
classItem < Sequel::Modelplugin:enumenum:condition,{mint: 10,good: 11,poor: 15}enditem=Item.create(:condition=>:mint)printitem[:condition]#> 10You can set the raw value through the []= accessor:
item[:condition]=15printitem.condition#> :poor- Fork it ( http://github.com/planas/sequel_enum/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request