Class: ComponentHost::Signal::Substitute::Signal
- Inherits:
-
Object
- Object
- ComponentHost::Signal::Substitute::Signal
- Defined in:
- lib/component_host/signal.rb
Defined Under Namespace
Classes: Record
Instance Method Summary collapse
- #handlers ⇒ Object
- #records ⇒ Object
- #send(signal) ⇒ Object
- #trap(signal, &handler) ⇒ Object
- #trapped?(signal = nil) ⇒ Boolean
Instance Method Details
#handlers ⇒ Object
39 40 41 |
# File 'lib/component_host/signal.rb', line 39 def handlers @handlers ||= {} end |
#records ⇒ Object
43 44 45 |
# File 'lib/component_host/signal.rb', line 43 def records @records ||= [] end |
#send(signal) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/component_host/signal.rb', line 27 def send(signal) handler = handlers[signal] return if handler.nil? handler.() record = Record.new signal records << record record end |
#trap(signal, &handler) ⇒ Object
15 16 17 |
# File 'lib/component_host/signal.rb', line 15 def trap(signal, &handler) handlers[signal] = handler end |
#trapped?(signal = nil) ⇒ Boolean
19 20 21 22 23 24 25 |
# File 'lib/component_host/signal.rb', line 19 def trapped?(signal=nil) if signal.nil? records.any? else records.any? { |record| record.signal == signal } end end |