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 = MemCache.new('localhost:11211')

class C
  attr_accessor_with_default :foo, 'bar'
end

c = C.new
cache.set('c', c) # ok

c.foo = '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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages