Class: Wisper::ObjectRegistration

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

Instance Attribute Summary collapse

Attributes inherited from Registration

#listener, #on

Instance Method Summary collapse

Constructor Details

#initialize(listener, options) ⇒ ObjectRegistration

Returns a new instance of ObjectRegistration.



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

def initialize(listener, options)
  super(listener, options)
  @with = options[:with]
end

Instance Attribute Details

#withObject (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, *args) ⇒ Object



10
11
12
13
14
15
# File 'lib/wisper/registration/object.rb', line 10

def broadcast(event, *args)
  method_to_call = map_event_to_method(event)
  if should_broadcast?(event) && listener.respond_to?(method_to_call)
    listener.public_send(method_to_call, *args)
  end
end