Class: ActiveSupport::EncryptedConfiguration

Inherits:
EncryptedFile show all
Defined in:
activesupport/lib/active_support/encrypted_configuration.rb

Constant Summary

Constants inherited from EncryptedFile

ActiveSupport::EncryptedFile::CIPHER

Instance Attribute Summary

Attributes inherited from EncryptedFile

#content_path, #env_key, #key_path, #raise_if_missing_key

Instance Method Summary collapse

Methods inherited from EncryptedFile

#change, generate_key, #key

Constructor Details

#initialize(config_path:, key_path:, env_key:, raise_if_missing_key:) ⇒ EncryptedConfiguration

Returns a new instance of EncryptedConfiguration.



14
15
16
17
# File 'activesupport/lib/active_support/encrypted_configuration.rb', line 14

def initialize(config_path:, key_path:, env_key:, raise_if_missing_key:)
  super content_path: config_path, key_path: key_path,
    env_key: env_key, raise_if_missing_key: raise_if_missing_key
end

Instance Method Details

#configObject



32
33
34
# File 'activesupport/lib/active_support/encrypted_configuration.rb', line 32

def config
  @config ||= deserialize(read).deep_symbolize_keys
end

#readObject

Allow a config to be started without a file present



20
21
22
23
24
# File 'activesupport/lib/active_support/encrypted_configuration.rb', line 20

def read
  super
rescue ActiveSupport::EncryptedFile::MissingContentError
  ""
end

#write(contents) ⇒ Object



26
27
28
29
30
# File 'activesupport/lib/active_support/encrypted_configuration.rb', line 26

def write(contents)
  deserialize(contents)

  super
end