Class: Clarion::Stores::Memory

Inherits:
Base
  • Object
show all
Defined in:
lib/clarion/stores/memory.rb

Instance Method Summary collapse

Constructor Details

#initializeMemory

Returns a new instance of Memory.



8
9
10
11
12
# File 'lib/clarion/stores/memory.rb', line 8

def initialize(*)
  super
  @lock = Mutex.new
  @store = {}
end

Instance Method Details

#find_authn(id) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/clarion/stores/memory.rb', line 20

def find_authn(id)
  @lock.synchronize do
    unless @store.key?(id)
      return nil
    end
    Authn.new(**@store[id])
  end
end

#store_authn(authn) ⇒ Object



14
15
16
17
18
# File 'lib/clarion/stores/memory.rb', line 14

def store_authn(authn)
  @lock.synchronize do
    @store[authn.id] = authn.to_h(:all)
  end
end