Class: YTLJit::ClassClassWrapper
Overview
Singleton class can’t be marshaled. So this class wrap to marshal singleton class
Constant Summary collapse
- @@instance_tab =
{}
Class Method Summary collapse
Instance Method Summary collapse
- #ancestors ⇒ Object
-
#initialize(clsobj) ⇒ ClassClassWrapper
constructor
A new instance of ClassClassWrapper.
- #marshal_dump ⇒ Object
- #marshal_load(obj) ⇒ Object
- #name ⇒ Object
- #superclass ⇒ Object
- #to_s ⇒ Object
- #value ⇒ Object
Constructor Details
#initialize(clsobj) ⇒ ClassClassWrapper
Returns a new instance of ClassClassWrapper.
71 72 73 74 |
# File 'lib/ytljit/util.rb', line 71 def initialize(clsobj) @klass_object = clsobj @value = nil end |
Class Method Details
.instance(clsobj) ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/ytljit/util.rb', line 57 def self.instance(clsobj) ins = @@instance_tab[clsobj] if ins == nil then ins = ClassClassWrapper.new(clsobj) @@instance_tab[clsobj] = ins end ins end |
.instance_tab ⇒ Object
67 68 69 |
# File 'lib/ytljit/util.rb', line 67 def self.instance_tab @@instance_tab end |
Instance Method Details
#ancestors ⇒ Object
93 94 95 |
# File 'lib/ytljit/util.rb', line 93 def ancestors value.ancestors end |
#marshal_dump ⇒ Object
97 98 99 |
# File 'lib/ytljit/util.rb', line 97 def marshal_dump [@klass_object] end |
#marshal_load(obj) ⇒ Object
101 102 103 104 |
# File 'lib/ytljit/util.rb', line 101 def marshal_load(obj) @klass_object = obj[0] @value = nil end |
#name ⇒ Object
89 90 91 |
# File 'lib/ytljit/util.rb', line 89 def name value.name end |
#superclass ⇒ Object
106 107 108 109 110 111 112 113 114 |
# File 'lib/ytljit/util.rb', line 106 def superclass sup = value.superclass ins = @@instance_tab[sup] if ins then ins else sup end end |
#to_s ⇒ Object
76 77 78 |
# File 'lib/ytljit/util.rb', line 76 def to_s "#<Ytljit::ClassClassWrapper type=#{value.inspect}" end |
#value ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/ytljit/util.rb', line 80 def value if @value then @value else @value = class << @klass_object; self; end @value end end |