Backport #1744: Error with Marshal dump/load on a delegated class.
http://redmine.ruby-lang.org/issues/show/1744

Author: Guillaume Delugré
Status: Open, Priority: Normal

Instance variables are not handled when using Marshal with a delegated class.

Here is an example :
on Ruby 1.8, the instance variable @var will be copied fine.
on Ruby 1.9.1, it is set to nil.

It seems to only occur with class inherited from DelegateClass.

==================================
require 'delegate'

class C < DelegateClass(Integer)
  attr_accessor :var

  def initialize
    @var = 1
  end
end

c = C.new
p c.var # => 1

d = Marshal.load(Marshal.dump(c))
p d.var # => nil on Ruby 1.9
==================================


----------------------------------------
http://redmine.ruby-lang.org