Skip to content

Instantly share code, notes, and snippets.

@jbarnette
Created March 6, 2012 22:43
Show Gist options
  • Save jbarnette/1989514 to your computer and use it in GitHub Desktop.
Save jbarnette/1989514 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
@jbarnette
Copy link
Author

@krainboltgreene
Copy link

You could update the gist and use it as a microgem :)

@jbarnette
Copy link
Author

I absolutely could. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment