class Celluloid::Call
Calls represent requests to an actor
Attributes
arguments[R]
block[R]
method[R]
Public Class Methods
new(method, arguments = [], block = nil)
click to toggle source
# 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
Public Instance Methods
check(obj)
click to toggle source
# File lib/celluloid/calls.rb, line 29 def check(obj) raise NoMethodError, "undefined method `#{@method}' for #{obj.inspect}" unless obj.respond_to? @method begin arity = obj.method(@method).arity rescue NameError return end if arity >= 0 raise ArgumentError, "wrong number of arguments (#{@arguments.size} for #{arity})" if @arguments.size != arity elsif arity < -1 mandatory_args = -arity - 1 raise ArgumentError, "wrong number of arguments (#{@arguments.size} for #{mandatory_args}+)" if arguments.size < mandatory_args end rescue => ex raise AbortError.new(ex) end
dispatch(obj)
click to toggle source
# File lib/celluloid/calls.rb, line 23 def dispatch(obj) check(obj) _block = @block && @block.to_proc obj.public_send(@method, *@arguments, &_block) end
execute_block_on_receiver()
click to toggle source
# File lib/celluloid/calls.rb, line 19 def execute_block_on_receiver @block && @block.execution = :receiver end