Class: Dizby::UnknownObject

Inherits:
Object
  • Object
show all
Defined in:
lib/dizby/distributed/unknown.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(err, buf) ⇒ UnknownObject

Returns a new instance of UnknownObject.


8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/dizby/distributed/unknown.rb', line 8

def initialize(err, buf)
  case err.to_s
  when /uninitialized constant (\S+)/
    @name = $~[1]
  when %r{undefined class/module (\S+)}
    @name = $~[1]
  else
    @name = nil
  end

  @buf = buf
end

Instance Attribute Details

#buf (readonly)

Returns the value of attribute buf


21
22
23
# File 'lib/dizby/distributed/unknown.rb', line 21

def buf
  @buf
end

#name (readonly)

Returns the value of attribute name


21
22
23
# File 'lib/dizby/distributed/unknown.rb', line 21

def name
  @name
end

Class Method Details

._load(str)


23
24
25
26
27
# File 'lib/dizby/distributed/unknown.rb', line 23

def self._load(str)
  Marshal.load(str)
rescue NameError, ArgumentError
  UnknownObject.new($!, str)
end

Instance Method Details

#_dump(_)


29
30
31
# File 'lib/dizby/distributed/unknown.rb', line 29

def _dump(_)
  Marshal.dump(@buf)
end

#exception


37
38
39
# File 'lib/dizby/distributed/unknown.rb', line 37

def exception
  UnknownObjectError.new self
end

#reload


33
34
35
# File 'lib/dizby/distributed/unknown.rb', line 33

def reload
  self.class._load @buf
end