Class: Blender::EventDispatcher
- Inherits:
-
Object
- Object
- Blender::EventDispatcher
- Defined in:
- lib/blender/event_dispatcher.rb
Instance Attribute Summary collapse
-
#handlers ⇒ Object
readonly
Returns the value of attribute handlers.
Class Method Summary collapse
-
.def_forwarding_method(method_name) ⇒ Object
Define a method that will be forwarded to all.
Instance Method Summary collapse
-
#initialize ⇒ EventDispatcher
constructor
A new instance of EventDispatcher.
- #register(handler) ⇒ Object
Constructor Details
#initialize ⇒ EventDispatcher
Returns a new instance of EventDispatcher.
24 25 26 |
# File 'lib/blender/event_dispatcher.rb', line 24 def initialize @handlers = [] end |
Instance Attribute Details
#handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
23 24 25 |
# File 'lib/blender/event_dispatcher.rb', line 23 def handlers @handlers end |
Class Method Details
.def_forwarding_method(method_name) ⇒ Object
Define a method that will be forwarded to all
33 34 35 36 37 38 39 |
# File 'lib/blender/event_dispatcher.rb', line 33 def self.def_forwarding_method(method_name) class_eval(<<-END_OF_METHOD, __FILE__, __LINE__) def #{method_name}(*args) @handlers.each {|s| s.#{method_name}(*args)} end END_OF_METHOD end |
Instance Method Details
#register(handler) ⇒ Object
28 29 30 |
# File 'lib/blender/event_dispatcher.rb', line 28 def register(handler) @handlers << handler end |