Class: Celluloid::Call

Inherits:
Object show all
Defined in:
lib/vendor/celluloid/lib/celluloid/calls.rb

Overview

Calls represent requests to an actor

Direct Known Subclasses

AsyncCall, SyncCall

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(caller, method, arguments, block) ⇒ Call

Returns a new instance of Call.



6
7
8
9
# File 'lib/vendor/celluloid/lib/celluloid/calls.rb', line 6

def initialize(caller, method, arguments, block)
  @id = object_id # memoize object ID for serialization
  @caller, @method, @arguments, @block = caller, method, arguments, block
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



4
5
6
# File 'lib/vendor/celluloid/lib/celluloid/calls.rb', line 4

def arguments
  @arguments
end

#blockObject (readonly)

Returns the value of attribute block.



4
5
6
# File 'lib/vendor/celluloid/lib/celluloid/calls.rb', line 4

def block
  @block
end

#callerObject (readonly)

Returns the value of attribute caller.



4
5
6
# File 'lib/vendor/celluloid/lib/celluloid/calls.rb', line 4

def caller
  @caller
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/vendor/celluloid/lib/celluloid/calls.rb', line 4

def id
  @id
end

#methodObject (readonly)

Returns the value of attribute method.



4
5
6
# File 'lib/vendor/celluloid/lib/celluloid/calls.rb', line 4

def method
  @method
end

Instance Method Details

#check_signature(obj) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/vendor/celluloid/lib/celluloid/calls.rb', line 11

def check_signature(obj)
  unless obj.respond_to? @method
    raise NoMethodError, "undefined method `#{@method}' for #{obj.inspect}"
  end

  arity = obj.method(@method).arity
  if arity >= 0
    if arguments.size != arity
      raise ArgumentError, "wrong number of arguments (#{arguments.size} for #{arity})"
    end
  elsif arity < -1
    mandatory_args = -arity - 1
    if arguments.size < mandatory_args
      raise ArgumentError, "wrong number of arguments (#{arguments.size} for #{mandatory_args})"
    end
  end
end