Module: Roby::DRoby::V5::DRobyConstant::Dump
- Included in:
- EventGenerator, Relations::Graph
- Defined in:
- lib/roby/droby/v5/droby_constant.rb
Overview
Generic implementation of the constant-dumping method. This is to be included in all kind of classes which should be dumped by their constant name (for intance Relations::Graph).
Defined Under Namespace
Classes: ConstantResolutionFailed, MismatchingLocalConstant
Instance Method Summary collapse
-
#droby_dump(peer) ⇒ Object
Returns a DRobyConstant object which references
self
. - #droby_marshallable? ⇒ Boolean
Instance Method Details
#droby_dump(peer) ⇒ Object
Returns a DRobyConstant object which references self
. It checks that self
can actually be referenced locally by calling constant(name)
, or raises ArgumentError if it is not the case.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/roby/droby/v5/droby_constant.rb', line 46 def droby_dump(peer) if constant = DRobyConstant.valid_constants[self] return constant elsif !name raise ConstantResolutionFailed, "#{self}#name returned nil" end name = "::#{self.name}" begin local_constant = constant(name) rescue Exception => e Roby.warn "could not resolve constant name for #{self}" Roby.log_exception(e, Roby, :warn) raise ConstantResolutionFailed, "cannot resolve constant name for #{self}" end if local_constant == self DRobyConstant.valid_constants[self] = DRobyConstant.new(name, peer.known_siblings_for(self)) else raise MismatchingLocalConstant, "got DRobyConstant whose name '#{name}' resolves "\ "to #{local_constant}(#{local_constant.class}), "\ "not itself (#{self})" end end |
#droby_marshallable? ⇒ Boolean
73 74 75 |
# File 'lib/roby/droby/v5/droby_constant.rb', line 73 def droby_marshallable? true end |