Class: CoolId::Config
- Inherits:
-
Object
- Object
- CoolId::Config
- Defined in:
- lib/cool_id.rb
Overview
Configuration class for CoolId generation.
Instance Attribute Summary collapse
-
#alphabet ⇒ String?
readonly
The alphabet to use for generating IDs.
-
#id_field ⇒ Symbol?
readonly
The field to use for storing the ID in the model.
-
#length ⇒ Integer?
readonly
The length of the generated ID (excluding prefix and separator).
-
#max_retries ⇒ Integer?
readonly
The maximum number of retries when generating a unique ID.
-
#model_class ⇒ Class
readonly
The ActiveRecord model class associated with this configuration.
-
#prefix ⇒ String
readonly
The prefix for generated IDs.
Instance Method Summary collapse
-
#initialize(prefix:, model_class:, length: nil, alphabet: nil, max_retries: nil, id_field: nil) ⇒ Config
constructor
Initializes a new Config instance.
Constructor Details
#initialize(prefix:, model_class:, length: nil, alphabet: nil, max_retries: nil, id_field: nil) ⇒ Config
Initializes a new Config instance.
173 174 175 176 177 178 179 180 |
# File 'lib/cool_id.rb', line 173 def initialize(prefix:, model_class:, length: nil, alphabet: nil, max_retries: nil, id_field: nil) @prefix = validate_prefix(prefix) @length = length @alphabet = validate_alphabet(alphabet) @max_retries = max_retries @model_class = model_class @id_field = id_field end |
Instance Attribute Details
#alphabet ⇒ String? (readonly)
Returns The alphabet to use for generating IDs.
155 156 157 |
# File 'lib/cool_id.rb', line 155 def alphabet @alphabet end |
#id_field ⇒ Symbol? (readonly)
Returns The field to use for storing the ID in the model.
164 165 166 |
# File 'lib/cool_id.rb', line 164 def id_field @id_field end |
#length ⇒ Integer? (readonly)
Returns The length of the generated ID (excluding prefix and separator).
152 153 154 |
# File 'lib/cool_id.rb', line 152 def length @length end |
#max_retries ⇒ Integer? (readonly)
Returns The maximum number of retries when generating a unique ID.
158 159 160 |
# File 'lib/cool_id.rb', line 158 def max_retries @max_retries end |
#model_class ⇒ Class (readonly)
Returns The ActiveRecord model class associated with this configuration.
161 162 163 |
# File 'lib/cool_id.rb', line 161 def model_class @model_class end |
#prefix ⇒ String (readonly)
Returns The prefix for generated IDs.
149 150 151 |
# File 'lib/cool_id.rb', line 149 def prefix @prefix end |