Class: KO::Signals::Connection
- Inherits:
-
Object
- Object
- KO::Signals::Connection
- Defined in:
- lib/ko/signals/connection.rb
Instance Attribute Summary collapse
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#receiver ⇒ Object
readonly
Returns the value of attribute receiver.
-
#signal ⇒ Object
readonly
Returns the value of attribute signal.
Instance Method Summary collapse
-
#call(*args, force_direct: false) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
- #disconnect ⇒ Object
-
#initialize(receiver, signal, mode:, one_shot:) ⇒ Connection
constructor
A new instance of Connection.
- #one_shot? ⇒ Boolean
Constructor Details
#initialize(receiver, signal, mode:, one_shot:) ⇒ Connection
Returns a new instance of Connection.
8 9 10 11 12 13 |
# File 'lib/ko/signals/connection.rb', line 8 def initialize(receiver, signal, mode:, one_shot:) @receiver = receiver @signal = signal @mode = mode @one_shot = one_shot end |
Instance Attribute Details
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
6 7 8 |
# File 'lib/ko/signals/connection.rb', line 6 def mode @mode end |
#receiver ⇒ Object (readonly)
Returns the value of attribute receiver.
6 7 8 |
# File 'lib/ko/signals/connection.rb', line 6 def receiver @receiver end |
#signal ⇒ Object (readonly)
Returns the value of attribute signal.
6 7 8 |
# File 'lib/ko/signals/connection.rb', line 6 def signal @signal end |
Instance Method Details
#call(*args, force_direct: false) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
17 18 19 20 21 22 23 |
# File 'lib/ko/signals/connection.rb', line 17 def call(*args, force_direct: false) # rubocop:disable Lint/UnusedMethodArgument @receiver.call(*args) rescue StandardError => e warn(e) ensure disconnect if one_shot? end |
#disconnect ⇒ Object
25 |
# File 'lib/ko/signals/connection.rb', line 25 def disconnect = @signal.disconnect(@receiver) |
#one_shot? ⇒ Boolean
15 |
# File 'lib/ko/signals/connection.rb', line 15 def one_shot? = @one_shot |