Class: Mnemosyne::Registry
- Inherits:
-
Object
- Object
- Mnemosyne::Registry
show all
- Defined in:
- lib/mnemosyne/registry.rb
Defined Under Namespace
Classes: Monitor, Registration
Instance Method Summary
collapse
Constructor Details
27
28
29
30
31
|
# File 'lib/mnemosyne/registry.rb', line 27
def initialize
@registrations = []
@activated = false
@monitor = Monitor.new
end
|
Instance Method Details
#activate! ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/mnemosyne/registry.rb', line 33
def activate!
return if activated?
@registrations.each(&method(:activate))
@activated = true
end
|
#activated? ⇒ Boolean
41
42
43
|
# File 'lib/mnemosyne/registry.rb', line 41
def activated?
@activated
end
|
#register(*args) ⇒ Object
45
46
47
48
49
|
# File 'lib/mnemosyne/registry.rb', line 45
def register(*args)
@registrations << (registration = Registration.new(*args))
activate(registration) if activated?
end
|
#required(path) ⇒ Object
51
52
53
54
55
56
|
# File 'lib/mnemosyne/registry.rb', line 51
def required(path)
return unless activated?
return unless (set = monitor.delete(path))
set.each(&method(:activate))
end
|