Okay, first of all I’m fairly new to Ruby, so it’s quite possible
there’s some essential concept I haven’t grasped yet, but this strikes
me as extremely weird:
irb(main):001:0> require ‘rexml/document’
true
irb(main):002:0> require ‘pstore’
true
irb(main):003:0> doc = REXML::Document.new(File.open(‘server.xml’))
[ lots of output, omitted for clarity ]
irb(main):004:0> ps = PStore.new(’_db/server’)
#<PStore:0x403ec7f4 @transaction=false, @abort=false,
@filename="_db/server">
irb(main):005:0> ps.transaction do
irb(main):006:1* ps[’/’] = doc
irb(main):007:1> end
TypeError: singleton can’t be dumped
from /usr/local/lib/ruby-1.6.7/lib/ruby/1.6/pstore.rb:111:in dump' from /usr/local/lib/ruby-1.6.7/lib/ruby/1.6/pstore.rb:111:in \transaction’
from (irb):5
Now, I didn’t believe for a moment that REXML::Document could actually
be a singleton, but by way of due diligence I did:
So, can anybody hazard a guess as to what’s going on here?
Hmm … as I write this, it occurs to me this could be an irb bug. I’ll
try it with plain ruby and see what happens. If you don’t hear from
again in the next 10 minutes, assume that I got the same results again.
The subject should be “Marshal::dump thinks REXML document is a
singleton?!” And I’ve confirmed that the same error occurs regardless of
whether I’m using irb or not.
I also took a quick tour through the REXML code, thinking that perhaps
some member object of the document might be a singleton, but I didn’t
find anything even suggestive of singletonness anywhere: no private
constructors, no inheritance from singleton classes (unless it’s very
well hidden).
I wonder how Marshal determines that an object is a singleton?
Apparently it’s implemented in C, so browsing the source code probably
wouldn’t help me much.
I wonder if there might be a singleton method
attached to the object? Just a thought.
Hal
···
----- Original Message -----
From: “Matt Gushee” mgushee@havenrock.com
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Wednesday, September 04, 2002 12:55 PM
Subject: Re: PStore thinks REXML document is a singleton?!
A little bit more info:
The subject should be “Marshal::dump thinks REXML document is a
singleton?!” And I’ve confirmed that the same error occurs regardless of
whether I’m using irb or not.
I also took a quick tour through the REXML code, thinking that perhaps
some member object of the document might be a singleton, but I didn’t
find anything even suggestive of singletonness anywhere: no private
constructors, no inheritance from singleton classes (unless it’s very
well hidden).
I wonder how Marshal determines that an object is a singleton?
Apparently it’s implemented in C, so browsing the source code probably
wouldn’t help me much.