class Slosilo::Keystore

Public Instance Methods

adapter() click to toggle source
# File lib/slosilo/keystore.rb, line 5
def adapter 
  Slosilo::adapter or raise "No Slosilo adapter is configured or available"
end
any?() { |k| ... } click to toggle source
# File lib/slosilo/keystore.rb, line 33
def any? &block
  each do |_, k|
    return true if yield k
  end
  return false
end
each() { |k, v| ... } click to toggle source
# File lib/slosilo/keystore.rb, line 29
def each &_
  adapter.each { |k, v| yield k, v }
end
get(opts) click to toggle source
# File lib/slosilo/keystore.rb, line 15
def get opts
  id, fingerprint = opts.is_a?(Hash) ? [nil, opts[:fingerprint]] : [opts, nil]
  if id
    key = adapter.get_key(id.to_s)
  elsif fingerprint
    key, _ = get_by_fingerprint(fingerprint)
  end
  key
end
get_by_fingerprint(fingerprint) click to toggle source
# File lib/slosilo/keystore.rb, line 25
def get_by_fingerprint fingerprint
  adapter.get_by_fingerprint fingerprint
end
put(id, key) click to toggle source
# File lib/slosilo/keystore.rb, line 9
def put id, key
  id = id.to_s
  fail ArgumentError, "id can't be empty" if id.empty?
  adapter.put_key id, key
end