Change Registry to a class

This commit is contained in:
Michael Miller 2019-11-09 23:05:22 -07:00
parent e0d12e9d0d
commit e4aae1f60a

View file

@ -1,7 +1,5 @@
module Spectator::Mocks module Spectator::Mocks
module Registry class Registry
extend self
alias Key = Tuple(String, UInt64) alias Key = Tuple(String, UInt64)
private struct Entry private struct Entry
@ -9,14 +7,14 @@ module Spectator::Mocks
getter calls = Deque(MethodCall).new getter calls = Deque(MethodCall).new
end end
@@entries = {} of Key => Entry @entries = {} of Key => Entry
def prepare(context : TestContext) : Nil def prepare(context : TestContext) : Nil
# TODO # TODO
end end
def reset : Nil def reset : Nil
@@entries.clear @entries.clear
end end
def add_stub(object, stub : MethodStub) : Nil def add_stub(object, stub : MethodStub) : Nil
@ -39,10 +37,10 @@ module Spectator::Mocks
private def fetch(object) private def fetch(object)
key = unique_key(object) key = unique_key(object)
if @@entries.has_key?(key) if @entries.has_key?(key)
@@entries[key] @entries[key]
else else
@@entries[key] = Entry.new @entries[key] = Entry.new
end end
end end