Class: KeeperSecretsManager::Storage::FileStorage
- Inherits:
-
Object
- Object
- KeeperSecretsManager::Storage::FileStorage
- Includes:
- KeyValueStorage
- Defined in:
- lib/keeper_secrets_manager/storage.rb
Overview
File-based storage implementation
Instance Method Summary collapse
- #delete(key) ⇒ Object
- #get_string(key) ⇒ Object
-
#initialize(filename = 'keeper_config.json') ⇒ FileStorage
constructor
A new instance of FileStorage.
- #save_string(key, value) ⇒ Object
Methods included from KeyValueStorage
#contains?, #get_bytes, #save_bytes
Constructor Details
#initialize(filename = 'keeper_config.json') ⇒ FileStorage
Returns a new instance of FileStorage.
119 120 121 122 123 |
# File 'lib/keeper_secrets_manager/storage.rb', line 119 def initialize(filename = 'keeper_config.json') @filename = File.(filename) @data = {} load_data end |
Instance Method Details
#delete(key) ⇒ Object
134 135 136 137 |
# File 'lib/keeper_secrets_manager/storage.rb', line 134 def delete(key) @data.delete(key.to_s) save_data end |
#get_string(key) ⇒ Object
125 126 127 |
# File 'lib/keeper_secrets_manager/storage.rb', line 125 def get_string(key) @data[key.to_s] end |
#save_string(key, value) ⇒ Object
129 130 131 132 |
# File 'lib/keeper_secrets_manager/storage.rb', line 129 def save_string(key, value) @data[key.to_s] = value.to_s save_data end |