{"id":13879460,"url":"https://github.com/AlexWayfer/sequel-enum_values","last_synced_at":"2025-07-16T15:32:22.158Z","repository":{"id":26035224,"uuid":"107161936","full_name":"AlexWayfer/sequel-enum_values","owner":"AlexWayfer","description":"Sequel plugin that provides method for getting `pg_enum` values","archived":false,"fork":false,"pushed_at":"2024-11-15T20:17:11.000Z","size":132,"stargazers_count":9,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-24T00:57:27.291Z","etag":null,"topics":["ruby","sequel","sequel-enum-values","sequel-plugin"],"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/AlexWayfer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-16T17:43:21.000Z","updated_at":"2024-11-01T15:19:30.000Z","dependencies_parsed_at":"2023-02-13T22:00:32.572Z","dependency_job_id":"ae552476-cb50-47d0-bb6d-74175a102a36","html_url":"https://github.com/AlexWayfer/sequel-enum_values","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexWayfer%2Fsequel-enum_values","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexWayfer%2Fsequel-enum_values/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexWayfer%2Fsequel-enum_values/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexWayfer%2Fsequel-enum_values/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlexWayfer","download_url":"https://codeload.github.com/AlexWayfer/sequel-enum_values/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226112994,"owners_count":17575438,"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","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":["ruby","sequel","sequel-enum-values","sequel-plugin"],"created_at":"2024-08-06T08:02:21.791Z","updated_at":"2024-11-24T08:31:21.790Z","avatar_url":"https://github.com/AlexWayfer.png","language":"Ruby","readme":"# Sequel enum_values plugin\n\n[![Cirrus CI - Base Branch Build Status](https://img.shields.io/cirrus/github/AlexWayfer/sequel-enum_values?style=flat-square)](https://cirrus-ci.com/github/AlexWayfer/sequel-enum_values)\n[![Codecov branch](https://img.shields.io/codecov/c/github/AlexWayfer/sequel-enum_values/main.svg?style=flat-square)](https://codecov.io/gh/AlexWayfer/sequel-enum_values)\n[![Code Climate](https://img.shields.io/codeclimate/maintainability/AlexWayfer/sequel-enum_values.svg?style=flat-square)](https://codeclimate.com/github/AlexWayfer/sequel-enum_values)\n[![Depfu](https://img.shields.io/depfu/AlexWayfer/sequel-enum_values?style=flat-square)](https://depfu.com/repos/github/AlexWayfer/sequel-enum_values)\n[![Inline docs](https://inch-ci.org/github/AlexWayfer/sequel-enum_values.svg?branch=main)](https://inch-ci.org/github/AlexWayfer/sequel-enum_values)\n[![Gem](https://img.shields.io/gem/v/sequel-enum_values.svg?style=flat-square)](https://rubygems.org/gems/sequel-enum_values)\n[![License](https://img.shields.io/github/license/AlexWayfer/sequel-enum_values.svg?style=flat-square)](LICENSE.txt)\n\nA Sequel plugin that provides `enum_values(field)` method to your models.\n\n## Installation\n\n### Bundler\n\nAdd this line to your project's Gemfile:\n\n```ruby\ngem 'sequel-enum_values', require: 'sequel/plugins/enum_values'\n```\n\nAnd then execute:\n\n```\n$ bundle\n```\n\n### Manually\n\nInstall this gem as:\n\n```\n$ gem install sequel-enum_values\n```\n\nAnd then require it in your project:\n\n```ruby\nrequire 'sequel/plugins/enum_values'\n```\n\n## Usage\n\nIf you have database schema like this:\n\n```ruby\ncreate_enum :item_type, %w[first second third]\ncreate_enum :item_status, %w[created selected canceled]\n\ncreate_table :items do\n  primary_key :id\n  column :type, :item_type\n  column :status, :item_status\nend\n```\n\nThen you can use it like this:\n\n```ruby\nclass Item \u003c Sequel::Model\n  plugin :enum_values\nend\n\nItem.enum_values(:type) # =\u003e [\"first\", \"second\", \"third\"]\nItem.enum_values(:status) # =\u003e [\"created\", \"selected\", \"canceled\"]\n```\n\n### Caching\n\nPlugin caches enum values for each field by default.\n\nBut you can disable it:\n\n```ruby\nItem.plugin :enum_values, caching: false\n```\n\n### Predicate methods\n\nPlugin can define instance methods for all enum values:\n\n```ruby\nItem.plugin :enum_values, predicate_methods: true # default is `false`\n\nitem = Item.new(type: 'first', status: 'created')\n\nitem.first? # =\u003e true\nitem.second? # =\u003e false\n\nitem.created? # =\u003e true\nitem.selected? # =\u003e false\n```\n\nOr just for specific fields:\n\n```ruby\nItem.plugin :enum_values, predicate_methods: %i[status]\n# or just `:status` for single value\n\nitem = Item.new(type: 'first', status: 'created')\n\nitem.first? # =\u003e NoMethodError\n\nitem.created? # =\u003e true\nitem.selected? # =\u003e false\n```\n\n## Development\n\nAfter checking out the repo, run `bundle install` to install dependencies.\n\nThen, run `toys rspec` to run the tests.\n\nTo install this gem onto your local machine, run `toys gem install`.\n\nTo release a new version, run `toys gem release %version%`.\nSee how it works [here](https://github.com/AlexWayfer/gem_toys#release).\n\n## Contributing\n\nBug reports and pull requests are welcome on [GitHub](https://github.com/AlexWayfer/sequel-enum_values).\n\n## License\n\nThe gem is available as open source under the terms of the\n[MIT License](https://opensource.org/licenses/MIT).\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAlexWayfer%2Fsequel-enum_values","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAlexWayfer%2Fsequel-enum_values","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAlexWayfer%2Fsequel-enum_values/lists"}