Module: Sequel::Plugins::ExternalId
- Defined in:
- lib/sequel/plugins/external_id.rb
Overview
Configures models with an external id that can be safely shared publicly and safely rotated. The external id is random, however it is prefixed with configurable strings that can indicate what type of model it represents. This disambiguates ids when shared pubnlically or in internal tooling.
This extension accepts a configuration option global_prefix:
that is a string prepended to all external IDs. This ensures
that your app's IDs clearly come from your app and not some other app that may be using external ids.
To use external ids you must then call ClassMethods#has_external_id in your model. This method accepts a string which is appended to the global prefix. This is then prepended to a unique identifier. The per-model external id prefix should indicate the type of the model. Note that it's not intended to be used programmatically—it's only for humans to quickly see what type of thing an identifier represents.
When ClassMethods#has_external_id is called on your model, the column external_id
will be set on save if it has no value.
Defined Under Namespace
Modules: ClassMethods, InstanceMethods
Class Method Summary collapse
Class Method Details
.global_prefix ⇒ Object
31 |
# File 'lib/sequel/plugins/external_id.rb', line 31 def self.global_prefix = @global_prefix |