Enumerize: Schema

RSpec Standard

Enumerize: Schema is wrapper around Enumerize that enables storing enum values in schema files.


Add this line to your application's Gemfile:

gem "enumerize-schema"

And then execute:

$ bundle install


Instead of using extend Enumerize, use extend EnumerizeSchema instead and define your enums with attr_enum:

class User
  extend EnumerizeSchema

  attr_enum :role

The values of the enum need to be listed in a YAML schema file. Here are the default paths for the schema file:

  • config/enumerize.yml in Ruby on Rails applications
  • enumerize.yml under Bundler.root (if Bundler is used) or the current working directory

The structure of the schema file is similar to the one of I18n locale files:

    - member
    - moderator
    - administrator


Options are forwarded to enumerize. If the :in option is specified then attr_enum will not check the schema file and the :in option will also be forwarded to enumerize.


After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.


Bug reports and pull requests are welcome on GitHub at https://github.com/RobertAudi/enumerize-schema.


The gem is available as open source under the terms of the MIT License.