Class: YTLJit::ClassClassWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/ytljit/util.rb

Overview

Singleton class can’t be marshaled. So this class wrap to marshal singleton class

Instance Method Summary collapse

Constructor Details

#initialize(clsobj) ⇒ ClassClassWrapper

Returns a new instance of ClassClassWrapper.



55
56
57
58
# File 'lib/ytljit/util.rb', line 55

def initialize(clsobj)
  @klass_object = clsobj
  @value = nil
end

Instance Method Details

#ancestorsObject



73
74
75
# File 'lib/ytljit/util.rb', line 73

def ancestors
  value.ancestors
end

#marshal_dumpObject



77
78
79
# File 'lib/ytljit/util.rb', line 77

def marshal_dump
  [@klass_object]
end

#marshal_load(obj) ⇒ Object



81
82
83
84
# File 'lib/ytljit/util.rb', line 81

def marshal_load(obj)
  @klass_object = obj
  @value = nil
end

#nameObject



69
70
71
# File 'lib/ytljit/util.rb', line 69

def name
  value.name
end

#valueObject



60
61
62
63
64
65
66
67
# File 'lib/ytljit/util.rb', line 60

def value
  if @value then
    @value
  else
    @value = class << @klass_object; self; end
    @value
  end
end