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.


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

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


19
20
21
# File 'lib/dizby/distributed/unknown.rb', line 19

def buf
  @buf
end

#name (readonly)

Returns the value of attribute name


19
20
21
# File 'lib/dizby/distributed/unknown.rb', line 19

def name
  @name
end

Class Method Details

._load(str)


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

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

Instance Method Details

#_dump(_)


27
28
29
# File 'lib/dizby/distributed/unknown.rb', line 27

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

#exception


35
36
37
# File 'lib/dizby/distributed/unknown.rb', line 35

def exception
  UnknownObjectError.new self
end

#reload


31
32
33
# File 'lib/dizby/distributed/unknown.rb', line 31

def reload
  self.class._load @buf
end