Created
August 22, 2009 17:26
-
-
Save methodmissing/172871 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
| class RubyCallback | |
| def initialize(object = nil, method = :call, &b) | |
| @object, @method = object, method | |
| @object ||= b | |
| end | |
| def call(*args) | |
| @object.__send__(@method, *args) | |
| end | |
| end | |
| module Kernel | |
| private | |
| def RubyCallback(object = nil, method = :call, &b) | |
| RubyCallback.new(object, method, &b) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment