Created
October 1, 2008 23:23
-
-
Save bakkdoor/14230 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_listener(superclass, methodname, &block) | |
focus_listener_class = Class.new() do | |
include superclass | |
implement superclass | |
def initialize(methodname, &block) | |
self.class.instance_eval do # <-- instance_eval makes this possible. :) | |
define_method(methodname, &block) | |
end | |
end | |
end | |
focus_listener_class.new(methodname, &block) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment