Breaking on objects with parameters in their initializers is just too brittle. It'd be smarter to try a series of strategies, in order:
- to_mongo if the object responds to from_mongo
- to_json if the object responds to from_json
- 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.)
- Marshal.dump if the object responds to Marshal.load
- 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).
Breaking on objects with parameters in their initializers is just too brittle. It'd be smarter to try a series of strategies, in order:
Method#parametersis implemented, as in Ruby 1.9.2.)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).