Created
January 8, 2009 04:04
-
-
Save jugyo/44577 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Termtter | |
class Client | |
def initialize | |
@hooks = [] | |
end | |
def add_hook(&block) | |
p block_given? | |
p block | |
@hooks << block | |
end | |
def call_hooks | |
@hooks.each do |h| h.call end | |
end | |
@@singleton = self.new | |
def self.method_missing(a, *args, &block) | |
@@singleton.__send__(a, *args, &block) | |
end | |
end | |
end | |
Termtter::Client.add_hook do | |
puts 'hook called' | |
end | |
Termtter::Client.call_hooks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment