Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/axsh/sequel_uuid_prefix
Sequel Model plugin that adds [0-9a-z] unique id prefixed by a custom string.
https://github.com/axsh/sequel_uuid_prefix
Last synced: about 2 months ago
JSON representation
Sequel Model plugin that adds [0-9a-z] unique id prefixed by a custom string.
- Host: GitHub
- URL: https://github.com/axsh/sequel_uuid_prefix
- Owner: axsh
- License: lgpl-3.0
- Created: 2014-12-16T06:06:28.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-12-16T10:21:43.000Z (about 10 years ago)
- Last Synced: 2024-11-10T22:14:29.315Z (about 2 months ago)
- Language: Ruby
- Size: 141 KB
- Stars: 0
- Watchers: 15
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# UUID Prefix
This is a Sequel Model plugin that adds [0-9a-z] unique ID prefixed by a custom string.
The prefix isn't stored in the database. Only the Unique ID itself is.
Usage:
```ruby
class Account < Sequel::Model
plugin Sequel::Plugins::UUIDPrefixuuid_prefix 'a'
endclass User < Sequel::Model
plugin Sequel::Plugins::UUIDPrefixuuid_prefix 'u'
end# Find an account.
UUIDPrefix.find('a-xxxxxxxx')# Find a user.
UUIDPrefix.find('u-xxxxxxxx')user1.uuid_prefix # == 'u'
user1.canonical_uuid # == 'u-abcd1234'Account['a-xxxxyyyy'] # Returns the account with UUID a-xxxxyyyy
Account.trim_uuid('a-abcd1234') # == 'abcd1234'
```