Class: Wisper::ObjectRegistration
- Inherits:
-
Object
- Object
- Wisper::ObjectRegistration
- Defined in:
- lib/wisper/async.rb
Instance Attribute Summary collapse
-
#async ⇒ Object
readonly
Returns the value of attribute async.
Instance Method Summary collapse
- #broadcast(event, publisher, *args) ⇒ Object
-
#initialize(listener, options) ⇒ ObjectRegistration
constructor
A new instance of ObjectRegistration.
- #old_initialize ⇒ Object
Constructor Details
#initialize(listener, options) ⇒ ObjectRegistration
Returns a new instance of ObjectRegistration.
12 13 14 15 |
# File 'lib/wisper/async.rb', line 12 def initialize(listener, ) @async = .delete(:async) { false } old_initialize(listener, ) end |
Instance Attribute Details
#async ⇒ Object (readonly)
Returns the value of attribute async.
8 9 10 |
# File 'lib/wisper/async.rb', line 8 def async @async end |
Instance Method Details
#broadcast(event, publisher, *args) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/wisper/async.rb', line 17 def broadcast(event, publisher, *args) method_to_call = map_event_to_method(event) if should_broadcast?(event) && listener.respond_to?(method_to_call) unless async listener.public_send(method_to_call, *args) else Async::Listener.new(listener, method_to_call).async.public_send(method_to_call, *args) end end end |
#old_initialize ⇒ Object
10 |
# File 'lib/wisper/async.rb', line 10 alias_method :old_initialize, :initialize |