lib/slosilo/keystore.rb in slosilo-0.1.2 vs lib/slosilo/keystore.rb in slosilo-0.2.2

- old
+ new

@@ -13,22 +13,19 @@ def get id key = adapter.get_key(id.to_s) key && Key.new(key) end - def each(&block) - adapter.each(&block) + def each &_ + adapter.each { |k, v| yield k, Key.new(v) } end def any? &block - catch :found do - adapter.each do |id, k| - throw :found if block.call(Key.new(k)) - end - return false + each do |_, k| + return true if yield k end - true + return false end end class << self def []= id, value @@ -47,9 +44,16 @@ self[:own].sign object end def token_valid? token keystore.any? { |k| k.token_valid? token } + end + + def token_signer token + each do |id, key| + return id if key.token_valid? token + end + return nil end attr_accessor :adapter private