C
christophe.poucet
Hello,
I was trying to marshal some objects, however some of these objects
contain references to singletons which of course can't be marshalled.
That's why I tried something as follows:
class Container
end
class SpecialContainer < Container
include Singleton
end
class Test
attr_accessor :container
def _dump(depth)
old = @container
if old == SpecialContainer.instance
@container = nil
end
result = super
@container = old
return result
end
def self._load(str)
super
if @container == nil
@container = SpecialContainer.instance
end
self
end
end
Sadly, however, it seems there is no default implementation for _dump,
which means that in this case the super call results in a
NoMethodError. Is there any other way to resolve this problem without
custom-coding a full _dump method?
Regards,
Christophe
I was trying to marshal some objects, however some of these objects
contain references to singletons which of course can't be marshalled.
That's why I tried something as follows:
class Container
end
class SpecialContainer < Container
include Singleton
end
class Test
attr_accessor :container
def _dump(depth)
old = @container
if old == SpecialContainer.instance
@container = nil
end
result = super
@container = old
return result
end
def self._load(str)
super
if @container == nil
@container = SpecialContainer.instance
end
self
end
end
Sadly, however, it seems there is no default implementation for _dump,
which means that in this case the super call results in a
NoMethodError. Is there any other way to resolve this problem without
custom-coding a full _dump method?
Regards,
Christophe