Class: Celluloid::Call
- Inherits:
-
Object
- Object
- Celluloid::Call
- Defined in:
- lib/celluloid/calls.rb
Overview
Calls represent requests to an actor
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#caller ⇒ Object
readonly
Returns the value of attribute caller.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
Instance Method Summary collapse
- #check_signature(obj) ⇒ Object
-
#initialize(caller, method, arguments = [], block = nil) ⇒ Call
constructor
A new instance of Call.
Constructor Details
#initialize(caller, method, arguments = [], block = nil) ⇒ Call
Returns a new instance of Call.
6 7 8 |
# File 'lib/celluloid/calls.rb', line 6 def initialize(caller, method, arguments = [], block = nil) @caller, @method, @arguments, @block = caller, method, arguments, block end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
4 5 6 |
# File 'lib/celluloid/calls.rb', line 4 def arguments @arguments end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
4 5 6 |
# File 'lib/celluloid/calls.rb', line 4 def block @block end |
#caller ⇒ Object (readonly)
Returns the value of attribute caller.
4 5 6 |
# File 'lib/celluloid/calls.rb', line 4 def caller @caller end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
4 5 6 |
# File 'lib/celluloid/calls.rb', line 4 def method @method end |
Instance Method Details
#check_signature(obj) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/celluloid/calls.rb', line 10 def check_signature(obj) unless obj.respond_to? @method raise NoMethodError, "undefined method `#{@method}' for #{obj.inspect}" end begin arity = obj.method(@method).arity rescue NameError # If the object claims it responds to a method, but it doesn't exist, # then we have to assume method_missing will do what it says @arguments.unshift(@method) @method = :method_missing return end 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 |