Parent

Class/Module Index [+]

Quicksearch

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

dispatch(obj) click to toggle source
# 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
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

[Validate]

Generated with the Darkfish Rdoc Generator 2.