Skip to content

Instantly share code, notes, and snippets.

@phiggins
Created December 3, 2010 07:24
Show Gist options
  • Save phiggins/726678 to your computer and use it in GitHub Desktop.
Save phiggins/726678 to your computer and use it in GitHub Desktop.
diff --git a/lib/em/spawnable.rb b/lib/em/spawnable.rb
index 2314213..ef64adc 100644
--- a/lib/em/spawnable.rb
+++ b/lib/em/spawnable.rb
@@ -45,15 +45,11 @@ module EventMachine
end
alias_method :resume, :notify
alias_method :run, :notify # for formulations like (EM.spawn {xxx}).run
- #attr_accessor :receiver
- #--
- # I know I'm missing something stupid, but the inside of class << s
- # can't see locally-bound values. It can see globals, though.
def set_receiver blk
- $em______tmpglobal = blk
- class << self
- define_method :call, $em______tmpglobal.dup
+ (class << self ; self ; end).class_eval do
+ remove_method :call if method_defined? :call
+ define_method :call, blk
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment