Class: SecureCredentials::EncryptedFile

Inherits:
ActiveSupport::EncryptedFile show all
Defined in:
lib/secure_credentials/encrypted_file.rb

Overview

Wraps ActiveSupport::EncryptedFile to accept key as an argument.

Constant Summary

Constants inherited from ActiveSupport::EncryptedFile

ActiveSupport::EncryptedFile::CIPHER

Instance Attribute Summary

Attributes inherited from ActiveSupport::EncryptedFile

#content_path, #env_key, #key_path, #raise_if_missing_key

Instance Method Summary collapse

Methods inherited from ActiveSupport::EncryptedFile

#change, generate_key, #read, #write

Constructor Details

#initialize(key: nil, key_path: nil, env_key: nil, **options) ⇒ EncryptedFile

Returns a new instance of EncryptedFile.



11
12
13
14
15
16
17
18
# File 'lib/secure_credentials/encrypted_file.rb', line 11

def initialize(key: nil, key_path: nil, env_key: nil, **options)
  @key = key
  super(
    **options,
    env_key: env_key,
    key_path: key_path || key && '' # original implementation does not accept nil
  )
end

Instance Method Details

#keyObject



20
21
22
# File 'lib/secure_credentials/encrypted_file.rb', line 20

def key
  @key || super
end