This project is archived and is in readonly mode.

#4776 open
Serge Balyuk

[PATCH] Fix attr_accessor_with_default causing TypeError "singleton can't be dumped"

Reported by Serge Balyuk | June 6th, 2010 @ 12:35 PM

The current attr_accessor_with_default implementation of writer method changes object's singleton class. That does not work well with marshaling, and such objects can't be easily put in memcache:

cache ='localhost:11211')

class C
  attr_accessor_with_default :foo, 'bar'

c =
cache.set('c', c) # ok = 'hello'
cache.set('c', c) # /usr/lib/ruby/1.8/memcache.rb:300:in `dump': singleton can't be dumped (TypeError)

Please find proposed patch that changes attr_accessor_with_default implementation so that it doesn't produce surprising changes in object singleton class.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>