Class: HatiConfig::Encryption::EnvKeyProvider
- Inherits:
-
KeyProvider
- Object
- KeyProvider
- HatiConfig::Encryption::EnvKeyProvider
- Defined in:
- lib/hati_config/encryption.rb
Overview
EnvKeyProvider gets the encryption key from an environment variable.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ EnvKeyProvider
constructor
A new instance of EnvKeyProvider.
- #key ⇒ Object
Methods inherited from KeyProvider
Constructor Details
#initialize(options = {}) ⇒ EnvKeyProvider
Returns a new instance of EnvKeyProvider.
189 190 191 192 |
# File 'lib/hati_config/encryption.rb', line 189 def initialize( = {}) super() @env_var = [:env_var] || 'HATI_CONFIG_ENCRYPTION_KEY' end |
Instance Method Details
#key ⇒ Object
194 195 196 197 198 199 |
# File 'lib/hati_config/encryption.rb', line 194 def key key = ENV.fetch(@env_var, nil) raise EncryptionError, "Encryption key not found in environment variable #{@env_var}" unless key key end |