Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
lighthouse-import opened this issue May 16, 2011 · 3 comments

Comments

@lighthouse-import
Copy link

Imported from Lighthouse. Original ticket at: http://rails.lighthouseapp.com/projects/8994/tickets/4776
Created by Serge Balyuk - 2011-04-09 22:41:51 UTC

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.

@lighthouse-import
Copy link
Author

Imported from Lighthouse.
Comment by Santiago Pastorino - 2011-02-02 16:37:59 UTC

This issue has been automatically marked as stale because it has not been commented on for at least three months.

The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

@lighthouse-import
Copy link
Author

Imported from Lighthouse.
Comment by Serge Balyuk - 2011-03-20 13:30:53 UTC

[state:open]

Per suggestion above, I've rebased against 3-0-stable and was able to successfully reproduce the issue in that branch.

Please find updated version of the patch attached.

@lighthouse-import
Copy link
Author

Attachments saved to Gist: http://gist.github.com/971673

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant