Class: TokenHawk::Storage::Memory

Inherits:
Object
  • Object
show all
Defined in:
lib/token_hawk/storage/memory.rb

Class Method Summary collapse

Class Method Details

.all ⇒ Object



14
15
16
# File 'lib/token_hawk/storage/memory.rb', line 14

def all
  @mutex.synchronize { @calls.dup }
end

.clear ⇒ Object



27
28
29
# File 'lib/token_hawk/storage/memory.rb', line 27

def clear
  @mutex.synchronize { @calls.clear }
end

.record(call) ⇒ Object



10
11
12
# File 'lib/token_hawk/storage/memory.rb', line 10

def record(call)
  @mutex.synchronize { @calls << call }
end

.where(domain: nil, since: nil) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/token_hawk/storage/memory.rb', line 18

def where(domain: nil, since: nil)
  @mutex.synchronize do
    @calls.select do |call|
      (domain.nil? || call.domain == domain) &&
        (since.nil? || call.created_at >= since)
    end
  end
end