Class: Roby::DRoby::V5::DRobyConstant

Inherits:
Object
  • Object
show all
Defined in:
lib/roby/droby/v5/droby_constant.rb

Overview

Dumps a constant by using its name. On reload, #proxy searches for a constant with the same name, and raises ArgumentError if none exists.

Examples:

dump instances of a class that are registered as constants

class Klass
  include DRobyConstant::Dump
end
# Obj can pass through droby
Obj = Klass.new

dump classes. You usually would prefer using DRobyModel

# Klass can pass through droby
class Klass
  extend DRobyConstant::Dump
end

Defined Under Namespace

Modules: Dump

Constant Summary collapse

@@valid_constants =
Hash.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, remote_siblings = Hash.new) ⇒ DRobyConstant

Returns a new instance of DRobyConstant.



69
70
71
72
# File 'lib/roby/droby/v5/droby_constant.rb', line 69

def initialize(name, remote_siblings = Hash.new)
    @name = name
    @remote_siblings = remote_siblings
end

Instance Attribute Details

#nameObject (readonly)

The constant name



67
68
69
# File 'lib/roby/droby/v5/droby_constant.rb', line 67

def name
  @name
end

#remote_siblingsObject (readonly)

Returns the value of attribute remote_siblings.



64
65
66
# File 'lib/roby/droby/v5/droby_constant.rb', line 64

def remote_siblings
  @remote_siblings
end

Class Method Details

.clear_cacheObject



20
21
22
# File 'lib/roby/droby/v5/droby_constant.rb', line 20

def self.clear_cache
    @@valid_constants.clear
end

.valid_constantsObject



25
# File 'lib/roby/droby/v5/droby_constant.rb', line 25

def self.valid_constants; @@valid_constants end

Instance Method Details

#proxy(peer) ⇒ Object

Returns the local object which can be referenced by this name, or raises ArgumentError.



75
# File 'lib/roby/droby/v5/droby_constant.rb', line 75

def proxy(peer); constant(name) end

#to_sObject



26
# File 'lib/roby/droby/v5/droby_constant.rb', line 26

def to_s; "#<dRoby:Constant #{name}>" end