Class: RakeSecrets::Storage::InMemory
- Defined in:
- lib/rake_secrets/storage/in_memory.rb
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ InMemory
constructor
A new instance of InMemory.
- #remove(path) ⇒ Object
- #retrieve(path) ⇒ Object
- #store(path, content) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ InMemory
Returns a new instance of InMemory.
9 10 11 12 |
# File 'lib/rake_secrets/storage/in_memory.rb', line 9 def initialize(opts = {}) super() @persistence = opts[:contents] || {} end |
Instance Method Details
#remove(path) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rake_secrets/storage/in_memory.rb', line 18 def remove(path) paths = matching_paths(path) if paths.empty? raise(Errors::NoSuchPathError, "Path '#{path}' not in storage.") end paths.each do |p| @persistence.delete(p) end end |
#retrieve(path) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/rake_secrets/storage/in_memory.rb', line 30 def retrieve(path) unless contains_exact_path?(path) raise(Errors::NoSuchPathError, "Path '#{path}' not in storage.") end @persistence[path] end |
#store(path, content) ⇒ Object
14 15 16 |
# File 'lib/rake_secrets/storage/in_memory.rb', line 14 def store(path, content) @persistence[path] = content end |