This repository was archived by the owner on Feb 18, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -28,10 +28,35 @@ public func ==(lhs:Stub, rhs:Stub) -> Bool {
28
28
return lhs. uuid == rhs. uuid
29
29
}
30
30
31
- var stubs = [ Stub] ( )
32
- var registered : Bool = false
31
+ class MockingjayStorage {
32
+ static let shared = MockingjayStorage ( )
33
+
34
+ var stubs : [ Stub ] {
35
+ get { accessQueue. sync { _stubs } }
36
+ set { accessQueue. sync { _stubs = newValue } }
37
+ }
38
+
39
+ var registered : Bool {
40
+ get { accessQueue. sync { _registered } }
41
+ set { accessQueue. sync { _registered = newValue } }
42
+ }
43
+
44
+ private var _stubs = [ Stub] ( )
45
+ private var _registered : Bool = false
46
+ private var accessQueue : DispatchQueue { DispatchQueue ( label: " MockingjayStorageQueue " , qos: . default) }
47
+ }
33
48
34
49
public class MockingjayProtocol : URLProtocol {
50
+ private class var storage : MockingjayStorage { . shared }
51
+ private class var stubs : [ Stub ] {
52
+ get { storage. stubs }
53
+ set { storage. stubs = newValue }
54
+ }
55
+ private class var registered : Bool {
56
+ get { storage. registered }
57
+ set { storage. registered = newValue }
58
+ }
59
+
35
60
// MARK: Stubs
36
61
fileprivate var enableDownloading = true
37
62
fileprivate let operationQueue = OperationQueue ( )
You can’t perform that action at this time.
0 commit comments