{"id":15805668,"url":"https://github.com/zhandao/configurable_enum","last_synced_at":"2025-08-14T00:16:58.535Z","repository":{"id":59152325,"uuid":"159272988","full_name":"zhandao/configurable_enum","owner":"zhandao","description":"Make ActiveRecord `enum` configurable: store the mapping in database instead of hard code","archived":false,"fork":false,"pushed_at":"2018-11-27T09:07:24.000Z","size":10,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-09T20:19:07.456Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zhandao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-27T03:52:00.000Z","updated_at":"2018-11-27T09:07:20.000Z","dependencies_parsed_at":"2022-09-13T11:00:50.350Z","dependency_job_id":null,"html_url":"https://github.com/zhandao/configurable_enum","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/zhandao/configurable_enum","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhandao%2Fconfigurable_enum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhandao%2Fconfigurable_enum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhandao%2Fconfigurable_enum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhandao%2Fconfigurable_enum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhandao","download_url":"https://codeload.github.com/zhandao/configurable_enum/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhandao%2Fconfigurable_enum/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269823278,"owners_count":24480776,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-05T02:22:06.668Z","updated_at":"2025-08-14T00:16:58.436Z","avatar_url":"https://github.com/zhandao.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ConfigurableEnum\n\nMake ActiveRecord `enum` configurable: store the mapping in database instead of hard code\n\n**Only Support `Integer` Value Currently**\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'configurable_enum'\n```\n\nAnd then execute:\n\n    $ bundle\n\n## Usage\n\n1. Setup: Generate mapping model and migration:  \n   `rails g configurable_enum:setup \u003cmodel_column\u003e`  \n   For example, you want to make `Book`'s column `category` to be enum: `rails g configurable_enum:setup book_category`  \n   It will Generate a model `BookCategroyMapping`\n   \n2. `rails db:migrate`\n   \n3. Declare in the model, like:\n    ```ruby\n    class Book \u003c ActiveRecord\n      configurable_enum :category\n    end\n    ```\n    \n4. You may want to init the enum mapping data, use:\n    ```ruby\n    hash = { science: 1 } # or { science: [1, 'remarks'] }\n    Book.set_categories(hash)\n    ```\n\nThat's all!\n\nOther methods:\n\n1. `Book.categories`\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/configurable_enum. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the ConfigurableEnum project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/configurable_enum/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhandao%2Fconfigurable_enum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhandao%2Fconfigurable_enum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhandao%2Fconfigurable_enum/lists"}