Class: RSwing::Components::Listener
- Inherits:
-
Object
- Object
- RSwing::Components::Listener
- Defined in:
- lib/rswing/components/listener.rb
Class Method Summary collapse
-
.create(listener_interface, methodname, &block) ⇒ Object
Creates a Listener-Class of the given listener_interface (Java Listener Interface) which has all interface methods implemented empty exceptt the one specified by
methodname.
Class Method Details
.create(listener_interface, methodname, &block) ⇒ Object
Creates a Listener-Class of the given listener_interface (Java Listener Interface) which has all interface methods implemented empty exceptt the one specified by methodname. Its method-body gets filled by the given block. Finally returns a new instance of this dynamically created Listener-Class.
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rswing/components/listener.rb', line 27 def self.create(listener_interface, methodname, &block) listener_class = Class.new() do include listener_interface implement listener_interface def initialize(methodname, &block) self.class.instance_eval do define_method(methodname, &block) end end end # return new instance of listener_class listener_class.new(methodname, &block) end |