ketsuban
Skip unlucky numbers for ActiveRecord surrogate key id
.
Usage
Gemfile:
gem 'ketsuban'
Some Model:
class User < ApplicationRecord
include Ketsuban
unlucky_numbers [4, 5]
end
5.times.map { User.create.id }
# => [1, 2, 3, 6, 7]
or
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.