Skip to content

Instantly share code, notes, and snippets.

@jugyo
Created January 8, 2009 04:04
Show Gist options
  • Save jugyo/44577 to your computer and use it in GitHub Desktop.
Save jugyo/44577 to your computer and use it in GitHub Desktop.
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