Skip to content

Instantly share code, notes, and snippets.

@methodmissing
Created August 22, 2009 17:26
Show Gist options
  • Select an option

  • Save methodmissing/172871 to your computer and use it in GitHub Desktop.

Select an option

Save methodmissing/172871 to your computer and use it in GitHub Desktop.
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