Created
March 17, 2016 17:41
-
-
Save jbodah/2647d8c9a50bd602b983 to your computer and use it in GitHub Desktop.
simple callbacks mixin
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
# To use, simply define @__callbacks as a hash where the keys are events | |
# and the values respond to #call (e.g. lambdas, procs, methods) | |
# | |
# This implementation assumes you only have one callback per event, but | |
# you could use an array instead if you wanted | |
module SimpleCallbacks | |
def run_callback(type, *args) | |
@__callbacks[type].call(*args) if @__callbacks.has_key?(type) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment