Class: Wisper::ObjectRegistration
- Inherits:
-
Registration
- Object
- Registration
- Wisper::ObjectRegistration
- Defined in:
- lib/wisper/registration/object.rb
Instance Attribute Summary collapse
-
#allowed_classes ⇒ Object
readonly
Returns the value of attribute allowed_classes.
-
#broadcaster ⇒ Object
readonly
Returns the value of attribute broadcaster.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#with ⇒ Object
readonly
Returns the value of attribute with.
Attributes inherited from Registration
Instance Method Summary collapse
- #broadcast(event, publisher, *args) ⇒ Object
-
#initialize(listener, options) ⇒ ObjectRegistration
constructor
A new instance of ObjectRegistration.
Constructor Details
#initialize(listener, options) ⇒ ObjectRegistration
Returns a new instance of ObjectRegistration.
5 6 7 8 9 10 11 |
# File 'lib/wisper/registration/object.rb', line 5 def initialize(listener, ) super(listener, ) @with = [:with] @prefix = stringify_prefix([:prefix]) @allowed_classes = Array([:scope]).map(&:to_s).to_set @broadcaster = map_broadcaster([:async] || [:broadcaster]) end |
Instance Attribute Details
#allowed_classes ⇒ Object (readonly)
Returns the value of attribute allowed_classes.
3 4 5 |
# File 'lib/wisper/registration/object.rb', line 3 def allowed_classes @allowed_classes end |
#broadcaster ⇒ Object (readonly)
Returns the value of attribute broadcaster.
3 4 5 |
# File 'lib/wisper/registration/object.rb', line 3 def broadcaster @broadcaster end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
3 4 5 |
# File 'lib/wisper/registration/object.rb', line 3 def prefix @prefix end |
#with ⇒ Object (readonly)
Returns the value of attribute with.
3 4 5 |
# File 'lib/wisper/registration/object.rb', line 3 def with @with end |
Instance Method Details
#broadcast(event, publisher, *args) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/wisper/registration/object.rb', line 13 def broadcast(event, publisher, *args) method_to_call = map_event_to_method(event) if should_broadcast?(event) && listener.respond_to?(method_to_call) && publisher_in_scope?(publisher) broadcaster.broadcast(listener, publisher, method_to_call, args) end end |