Skip to content

Instantly share code, notes, and snippets.

@Jupiterrr
Forked from jbarnette/watchable.rb
Created March 6, 2012 23:40
Show Gist options
  • Save Jupiterrr/1989812 to your computer and use it in GitHub Desktop.
Save Jupiterrr/1989812 to your computer and use it in GitHub Desktop.
module Watchable
def events
@events ||= Hash.new { |h,k| h[k] = [] }
end
def fire event, *args
events[event].each { |e| e[*args] }
end
def on event, &block
events[event] << block
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment