class Sekrat::Warehouse::Memory
An in-memory warehouse for storing secrets
Public Class Methods
new()
click to toggle source
# File lib/sekrat/warehouse/memory.rb, line 10 def initialize @storage = {} end
Public Instance Methods
ids()
click to toggle source
Get the list of ids for the secrets stored in the warehouse @return [Array<String>] the list of keys
# File lib/sekrat/warehouse/memory.rb, line 16 def ids storage.keys end
retrieve(id)
click to toggle source
Given an id, get its associated stored data @param id [String] the id of the secret @return [String] the secret data @raise [Sekrat::NotFound] if the secret does not exist
# File lib/sekrat/warehouse/memory.rb, line 32 def retrieve(id) raise NotFound.new("id '#{id}'") unless ids.include?(id) storage[id] end
store(id, data)
click to toggle source
Given an id and some data, store the data indexed by the id @param id [String] the id for the secret @param data [String] the data to store @return [String] the data stored
# File lib/sekrat/warehouse/memory.rb, line 24 def store(id, data) storage[id] = data end
Private Instance Methods
storage()
click to toggle source
# File lib/sekrat/warehouse/memory.rb, line 39 def storage @storage end