From: Robert Klemme Date: 2007-07-25T20:19:33+09:00 Subject: Re: Detecting singletons 2007/7/25, Lars Westergren : > I have a fairly large and complex object graph of Value Objects created > by soap4r and used in a Rails application. The app, which used to work, > now gets > Exception `TypeError' at > /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/transactions.rb:97 > - singleton can't be dumped > all over the place and I have narrowed it down to Marshal.dump being > used by Rails. > > I have aliased Marshal.dump so that I can inspect the objects passed > first, I thought that would be the fastest way to locate the problematic > object. My question is, how do I detect that an object is a singleton? > Should I test with "responds_to?" if the "new" method lacking or that > the "instance" method is there? Or is there an easier way? If Singleton === obj puts "it's a singleton!" end Kind regards robert