Class: Dradis::Plugins::Settings::Adapters::EncryptedConfiguration
- Inherits:
-
Object
- Object
- Dradis::Plugins::Settings::Adapters::EncryptedConfiguration
- Defined in:
- lib/dradis/plugins/settings/adapters/encrypted_configuration.rb
Instance Attribute Summary collapse
-
#config_path ⇒ Object
writeonly
Sets the attribute config_path.
Instance Method Summary collapse
- #delete(key) ⇒ Object
- #exists?(key) ⇒ Boolean
-
#initialize(namespace) ⇒ EncryptedConfiguration
constructor
A new instance of EncryptedConfiguration.
- #key_path=(string_or_pathname) ⇒ Object
- #read(key) ⇒ Object
- #write(key, value) ⇒ Object
Constructor Details
#initialize(namespace) ⇒ EncryptedConfiguration
Returns a new instance of EncryptedConfiguration.
5 6 7 |
# File 'lib/dradis/plugins/settings/adapters/encrypted_configuration.rb', line 5 def initialize(namespace) @namespace = namespace end |
Instance Attribute Details
#config_path=(value) ⇒ Object
Sets the attribute config_path
3 4 5 |
# File 'lib/dradis/plugins/settings/adapters/encrypted_configuration.rb', line 3 def config_path=(value) @config_path = value end |
Instance Method Details
#delete(key) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/dradis/plugins/settings/adapters/encrypted_configuration.rb', line 9 def delete(key) if exists?(key) configuration.config[@namespace].delete(key) configuration.write(configuration.config.to_yaml) end end |
#exists?(key) ⇒ Boolean
16 17 18 |
# File 'lib/dradis/plugins/settings/adapters/encrypted_configuration.rb', line 16 def exists?(key) !!configuration.config[@namespace]&.key?(key) end |
#key_path=(string_or_pathname) ⇒ Object
30 31 32 |
# File 'lib/dradis/plugins/settings/adapters/encrypted_configuration.rb', line 30 def key_path=(string_or_pathname) @key_path = Pathname.new(string_or_pathname) end |
#read(key) ⇒ Object
20 21 22 |
# File 'lib/dradis/plugins/settings/adapters/encrypted_configuration.rb', line 20 def read(key) configuration.config.fetch(@namespace, {}).fetch(key, nil) end |
#write(key, value) ⇒ Object
24 25 26 27 28 |
# File 'lib/dradis/plugins/settings/adapters/encrypted_configuration.rb', line 24 def write(key, value) configuration.config[@namespace] ||= {} configuration.config[@namespace][key] = value configuration.write(configuration.config.to_yaml) end |