Object
Calls represent requests to an actor
# File lib/celluloid/calls.rb, line 6 def initialize(method, arguments = [], block = nil) @method, @arguments = method, arguments if block if Celluloid.exclusive? # FIXME: nicer exception raise "Cannot execute blocks on sender in exclusive mode" end @block = BlockProxy.new(self, Celluloid.mailbox, block) else @block = nil end end
# File lib/celluloid/calls.rb, line 23 def dispatch(obj) _block = @block && @block.to_proc obj.public_send(@method, *@arguments, &_block) rescue NoMethodError => ex # Abort if the sender made a mistake raise AbortError.new(ex) unless obj.respond_to? @method # Otherwise something blew up. Crash this actor raise rescue ArgumentError => ex # Abort if the sender made a mistake begin arity = obj.method(@method).arity rescue NameError # In theory this shouldn't happen, but just in case raise AbortError.new(ex) end if arity >= 0 raise AbortError.new(ex) if @arguments.size != arity elsif arity < -1 mandatory_args = -arity - 1 raise AbortError.new(ex) if arguments.size < mandatory_args end # Otherwise something blew up. Crash this actor raise end
Generated with the Darkfish Rdoc Generator 2.