Class: Celluloid::Call
- Defined in:
- lib/vendor/celluloid/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.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
Instance Method Summary collapse
- #check_signature(obj) ⇒ Object
-
#initialize(caller, method, arguments, block) ⇒ Call
constructor
A new instance of Call.
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
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
4 5 6 |
# File 'lib/vendor/celluloid/lib/celluloid/calls.rb', line 4 def arguments @arguments end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
4 5 6 |
# File 'lib/vendor/celluloid/lib/celluloid/calls.rb', line 4 def block @block end |
#caller ⇒ Object (readonly)
Returns the value of attribute caller.
4 5 6 |
# File 'lib/vendor/celluloid/lib/celluloid/calls.rb', line 4 def caller @caller end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/vendor/celluloid/lib/celluloid/calls.rb', line 4 def id @id end |
#method ⇒ Object (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 |