No release in over a year
A wrapper around Enumerize to store enum values in schema files
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.14
~> 13.0
~> 3.2
~> 1.3
~> 0.9

Runtime

 Project Readme

Enumerize: Schema

RSpec Standard

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

Installation

Add this line to your application's Gemfile:

gem "enumerize-schema"

And then execute:

$ bundle install

Usage

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

class User
  extend EnumerizeSchema

  attr_enum :role
end

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:

---
user:
  role:
    - member
    - moderator
    - administrator

Options

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.

Development

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.

Contributing

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

License

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