Class: Wisper::ObjectRegistration Private

Inherits:
Registration show all
Defined in:
lib/wisper/registration/object.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Attributes inherited from Registration

#listener, #on

Instance Method Summary collapse

Constructor Details

#initialize(listener, **options) ⇒ ObjectRegistration

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ObjectRegistration.



7
8
9
10
11
12
13
# File 'lib/wisper/registration/object.rb', line 7

def initialize(listener, **options)
  super(listener, **options)
  @with   = options[:with]
  @prefix = ValueObjects::Prefix.new options[:prefix]
  @allowed_classes = Array(options[:scope]).map(&:to_s).to_set
  @broadcaster = map_broadcaster(options[:async] || options[:broadcaster])
end

Instance Attribute Details

#allowed_classesObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



5
6
7
# File 'lib/wisper/registration/object.rb', line 5

def allowed_classes
  @allowed_classes
end

#broadcasterObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



5
6
7
# File 'lib/wisper/registration/object.rb', line 5

def broadcaster
  @broadcaster
end

#prefixObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



5
6
7
# File 'lib/wisper/registration/object.rb', line 5

def prefix
  @prefix
end

#withObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



5
6
7
# File 'lib/wisper/registration/object.rb', line 5

def with
  @with
end

Instance Method Details

#broadcast(event, publisher, *args, **kwargs) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



15
16
17
18
19
20
# File 'lib/wisper/registration/object.rb', line 15

def broadcast(event, publisher, *args, **kwargs)
  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, **kwargs)
  end
end