S
Stephen Sykes
I would find it useful if Marshal were to use "allocate" to generate
new objects. This is so that I can load unknown objects by doing
something like this:
class Object
def self.const_missing(name)
const_set(name, kl = Class.new)
kl
end
end
And then be able to load objects with marshal without getting
ArgumentError: undefined class/module.
For example (after running the above code)...
irb(main):026:0> M.allocate
=> #<M:0x2bb2168>
That works ok, but...
irb(main):029:0> Marshal.load("\004\010o:\006N\000")
ArgumentError: undefined class/module N
from (irb):29:in `load'
from (irb):29
from (null):0
If Mashal used allocate, and hence called const_missing, then the load
would not fail. Sound reasonable?
Stephen Sykes
new objects. This is so that I can load unknown objects by doing
something like this:
class Object
def self.const_missing(name)
const_set(name, kl = Class.new)
kl
end
end
And then be able to load objects with marshal without getting
ArgumentError: undefined class/module.
For example (after running the above code)...
irb(main):026:0> M.allocate
=> #<M:0x2bb2168>
That works ok, but...
irb(main):029:0> Marshal.load("\004\010o:\006N\000")
ArgumentError: undefined class/module N
from (irb):29:in `load'
from (irb):29
from (null):0
If Mashal used allocate, and hence called const_missing, then the load
would not fail. Sound reasonable?
Stephen Sykes