https://github.com/oieioi/ketsuban
🍀 Skip unlucky numbers for ActiveRecord surrogate key
https://github.com/oieioi/ketsuban
activerecord rubygem
Last synced: 8 months ago
JSON representation
🍀 Skip unlucky numbers for ActiveRecord surrogate key
- Host: GitHub
- URL: https://github.com/oieioi/ketsuban
- Owner: oieioi
- License: mit
- Created: 2019-01-25T14:55:21.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-12-03T07:39:30.000Z (over 6 years ago)
- Last Synced: 2025-09-20T22:36:10.935Z (9 months ago)
- Topics: activerecord, rubygem
- Language: Ruby
- Homepage:
- Size: 52.7 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://rubygems.org/gems/ketsuban)
[](https://travis-ci.org/oieioi/ketsuban)
[](https://coveralls.io/github/oieioi/ketsuban?branch=master)
# ketsuban
Skip unlucky numbers for ActiveRecord surrogate key `id`.
## Usage
Gemfile:
```ruby
gem 'ketsuban'
```
Some Model:
```ruby
class User < ApplicationRecord
include Ketsuban
unlucky_numbers [4, 5]
end
5.times.map { User.create.id }
# => [1, 2, 3, 6, 7]
```
or
```ruby
class User < ApplicationRecord
include Ketsuban
unlucky_numbers ->(next_id) { next_id.odd? }
end
5.times.map { User.create.id }
# => [2, 4, 6, 8, 10]
```
`unlucky_numbers` is aliased `ketsuban`
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).