lib/celluloid/actor_proxy.rb in celluloid-0.7.2 vs lib/celluloid/actor_proxy.rb in celluloid-0.8.0
- old
+ new
@@ -39,11 +39,11 @@
"#<Celluloid::Actor(#{@klass}) dead>"
end
# Create a Celluloid::Future which calls a given method
def future(method_name, *args, &block)
- Future.new { Actor.call @mailbox, method_name, *args, &block }
+ Actor.future @mailbox, method_name, *args, &block
end
# Terminate the associated actor
def terminate
raise DeadActorError, "actor already terminated" unless alive?
@@ -60,16 +60,17 @@
nil
end
# method_missing black magic to call bang predicate methods asynchronously
def method_missing(meth, *args, &block)
+ meth = meth.to_s
+
# bang methods are async calls
- if meth.to_s.match(/!$/)
- unbanged_meth = meth.to_s.sub(/!$/, '')
- Actor.async @mailbox, unbanged_meth, *args, &block
- return
+ if meth.match(/!$/)
+ meth.sub!(/!$/, '')
+ Actor.async @mailbox, meth, *args, &block
+ else
+ Actor.call @mailbox, meth, *args, &block
end
-
- Actor.call @mailbox, meth, *args, &block
end
end
end