Skip to content

Instantly share code, notes, and snippets.

@bakkdoor
Created October 1, 2008 23:23
Show Gist options
  • Save bakkdoor/14230 to your computer and use it in GitHub Desktop.
Save bakkdoor/14230 to your computer and use it in GitHub Desktop.
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