Sha256: c6b3a447fe8d09179c1325c345321389b5c2354516d91c28219eed27fbabb75d
Contents?: true
Size: 1010 Bytes
Versions: 7
Compression:
Stored size: 1010 Bytes
Contents
# frozen_string_literal: true require_relative 'base' require_relative '../errors' module RakeSecrets module Storage class InMemory < Base def initialize(opts = {}) super() @persistence = opts[:contents] || {} end def store(path, content) @persistence[path] = content end 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 def retrieve(path) unless contains_exact_path?(path) raise(Errors::NoSuchPathError, "Path '#{path}' not in storage.") end @persistence[path] end private def contains_exact_path?(path) @persistence.include?(path) end def matching_paths(path) @persistence.select { |k| k == path or k.start_with?(path) }.keys end end end end
Version data entries
7 entries across 7 versions & 1 rubygems