Class: Foobara::Namespace::UnambiguousRegistry
- Inherits:
-
BaseRegistry
show all
- Defined in:
- foobara-0.0.110/projects/namespace/src/unambiguous_registry.rb
Instance Method Summary
collapse
#all_scoped, #apply_filter, #each_scoped, #registered?
Instance Method Details
#each_scoped_without_filter ⇒ Object
43
44
45
46
|
# File 'foobara-0.0.110/projects/namespace/src/unambiguous_registry.rb', line 43
def each_scoped_without_filter(&)
all.dup.each(&)
end
|
#lookup(path, filter = nil) ⇒ Object
39
40
41
|
# File 'foobara-0.0.110/projects/namespace/src/unambiguous_registry.rb', line 39
def lookup(path, filter = nil)
apply_filter(registry[path], filter)
end
|
#register(scoped) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'foobara-0.0.110/projects/namespace/src/unambiguous_registry.rb', line 10
def register(scoped)
new_entries = {}
to_keys(scoped).each do |key|
if registry.key?(key)
raise WouldMakeRegistryAmbiguousError,
"Ambiguous match for #{key.inspect}. Matches the following: #{registry[key].inspect}"
end
new_entries[key] = scoped
end
all << scoped
registry.merge!(new_entries)
end
|
#registry ⇒ Object
6
7
8
|
# File 'foobara-0.0.110/projects/namespace/src/unambiguous_registry.rb', line 6
def registry
@registry ||= {}
end
|
#unregister(scoped) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
|
# File 'foobara-0.0.110/projects/namespace/src/unambiguous_registry.rb', line 27
def unregister(scoped)
all.delete(scoped)
to_keys(scoped).each do |key|
unless registry.key?(key)
raise NotRegisteredError, "Not registered: #{key.inspect}"
end
registry.delete(key)
end
end
|