Class: KSUID::Configuration
- Inherits:
-
Object
- Object
- KSUID::Configuration
- Defined in:
- lib/ksuid/configuration.rb
Overview
Encapsulates the configuration for the KSUID gem as a whole.
You can override the generation of the random payload data by setting the #random_generator value to a valid random payload generator. This should be done via the module-level configure method.
The gem-level configuration lives at the module-level config.
Constant Summary collapse
- ConfigurationError =
Raised when the gem is misconfigured.
Class.new(StandardError)
Instance Attribute Summary collapse
-
#random_generator ⇒ #call
private
The method for generating random payloads in the gem.
Class Method Summary collapse
-
.default_generator ⇒ Proc
private
The default generator for generating random payloads.
Instance Method Summary collapse
-
#initialize ⇒ KSUID::Configuration
constructor
private
Instantiates a new KSUID configuration.
Constructor Details
#initialize ⇒ KSUID::Configuration
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Instantiates a new KSUID configuration
33 34 35 |
# File 'lib/ksuid/configuration.rb', line 33 def initialize self.random_generator = self.class.default_generator end |
Instance Attribute Details
#random_generator ⇒ #call
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The method for generating random payloads in the gem
42 43 44 |
# File 'lib/ksuid/configuration.rb', line 42 def random_generator @random_generator end |
Class Method Details
.default_generator ⇒ Proc
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The default generator for generating random payloads
24 25 26 |
# File 'lib/ksuid/configuration.rb', line 24 def self.default_generator -> { SecureRandom.random_bytes(BYTES[:payload]) } end |