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
9
# File 'lib/wisper/registration/object.rb', line 5

def initialize(listener, options)
  super(listener, options)
  @with  = options[:with]
  fail_on_async if options.has_key?(:async)
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



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

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