Created
August 21, 2008 11:54
-
-
Save taka2/6543 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
module Rubeus::Extensions::Javax::Swing | |
module Timer | |
def self.included(base) | |
base.extend ClassMethods | |
base.instance_eval do | |
alias :new_without_rubeus :new | |
alias :new :new_with_rubeus | |
end | |
end | |
module ClassMethods | |
def new_with_rubeus(interval, &block) | |
# Create ActionListener implement class | |
mod = Module.new do | |
define_method("actionPerformed", &block) | |
end | |
obj = Object.new | |
obj.extend(mod) | |
# Use original constructor | |
new_without_rubeus(interval, obj) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment