Class: DRb::DRbUnknown
- Inherits:
-
Object
- Object
- DRb::DRbUnknown
- Defined in:
- lib/drb/drb.rb
Overview
Class wrapping a marshalled object whose type is unknown locally.
If an object is returned by a method invoked over drb, but the class of the object is unknown in the client namespace, or the object is a constant unknown in the client namespace, then the still-marshalled object is returned wrapped in a DRbUnknown instance.
If this object is passed as an argument to a method invoked over drb, then the wrapped object is passed instead.
The class or constant name of the object can be read from the name
attribute. The marshalled object is held in the buf
attribute.
Instance Attribute Summary collapse
-
#buf ⇒ Object
readonly
Buffer contained the marshalled, unknown object.
-
#name ⇒ Object
readonly
The name of the unknown thing.
Class Method Summary collapse
-
._load(s) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#_dump(lv) ⇒ Object
:nodoc:.
-
#exception ⇒ Object
Create a DRbUnknownError exception containing this object.
-
#initialize(err, buf) ⇒ DRbUnknown
constructor
Create a new DRbUnknown object.
-
#reload ⇒ Object
Attempt to load the wrapped marshalled object again.
Constructor Details
#initialize(err, buf) ⇒ DRbUnknown
Create a new DRbUnknown object.
buf
is a string containing a marshalled object that could not be unmarshalled. err
is the error message that was raised when the unmarshalling failed. It is used to determine the name of the unmarshalled object.
464 465 466 467 468 469 470 471 472 473 474 |
# File 'lib/drb/drb.rb', line 464 def initialize(err, buf) case err.to_s when /uninitialized constant (\S+)/ @name = $1 when /undefined class\/module (\S+)/ @name = $1 else @name = nil end @buf = buf end |
Instance Attribute Details
#buf ⇒ Object (readonly)
Buffer contained the marshalled, unknown object.
483 484 485 |
# File 'lib/drb/drb.rb', line 483 def buf @buf end |
#name ⇒ Object (readonly)
The name of the unknown thing.
Class name for unknown objects; variable name for unknown constants.
480 481 482 |
# File 'lib/drb/drb.rb', line 480 def name @name end |
Class Method Details
._load(s) ⇒ Object
:nodoc:
485 486 487 488 489 490 491 |
# File 'lib/drb/drb.rb', line 485 def self._load(s) # :nodoc: begin Marshal::load(s) rescue NameError, ArgumentError DRbUnknown.new($!, s) end end |
Instance Method Details
#_dump(lv) ⇒ Object
:nodoc:
493 494 495 |
# File 'lib/drb/drb.rb', line 493 def _dump(lv) # :nodoc: @buf end |
#exception ⇒ Object
Create a DRbUnknownError exception containing this object.
507 508 509 |
# File 'lib/drb/drb.rb', line 507 def exception DRbUnknownError.new(self) end |
#reload ⇒ Object
Attempt to load the wrapped marshalled object again.
If the class of the object is now known locally, the object will be unmarshalled and returned. Otherwise, a new but identical DRbUnknown object will be returned.
502 503 504 |
# File 'lib/drb/drb.rb', line 502 def reload self.class._load(@buf) end |