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

Need more robust serialization of non-Candy objects #9

Open
SFEley opened this issue May 5, 2010 · 0 comments
Open

Need more robust serialization of non-Candy objects #9

SFEley opened this issue May 5, 2010 · 0 comments

Comments

@SFEley
Copy link
Owner

SFEley commented May 5, 2010

Breaking on objects with parameters in their initializers is just too brittle. It'd be smarter to try a series of strategies, in order:

  1. to_mongo if the object responds to from_mongo
  2. to_json if the object responds to from_json
  3. The current Candy::Wrapper class-and-ivars serialization if the object initializer's arity is 0 (Note: make it even smarter if Method#parameters is implemented, as in Ruby 1.9.2.)
  4. Marshal.dump if the object responds to Marshal.load
  5. Throw an exception if none of the above works.

This is the chain of maximum usefulness within MongoDB queries or data loads. In any of those cases we'll still need to store the strategy used and the class name (except for Marshal).

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