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

Extract serialization/deserialization #10

Closed
jgaskins opened this issue Nov 19, 2012 · 2 comments
Closed

Extract serialization/deserialization #10

jgaskins opened this issue Nov 19, 2012 · 2 comments

Comments

@jgaskins
Copy link
Owner

Objects are currently serialized in Mapper but deserialized in Retrieval. I felt horrible about doing it this way, but it was necessary to get the functionality I needed. What I'd like to do is extract all of that behavior from both of those classes into Serializer objects.

Then in the Mapper, we can do something like Serializer.new(object).serialize and in Retrieval Serializer.new(serialized_data).unserialize. This will also make it easier to extract state injection from Mapper and Retrieval objects (where it doesn't belong).

@jgaskins
Copy link
Owner Author

While working on this, I have been unable to come up with a way to keep a unidirectional dependency graph in a clean way. The problem comes about when we need to serialize an object that contains other objects that the DB cannot serialize natively. For example, if we have an Article that contains an array of Comments, we need to know how to serialize the comments, too. But in order to do that, we need to know which attributes to serialize on it, which are defined within its mapper. Then we have a mapper that depends on a serializer which, in turn, depends on another mapper.

The only way I've been able to come up with to do this without circular dependencies is for the first mapper to pass along the attribute sets (or maybe full mappers?) for each not-natively serializable object in the first object's graph. I'm not sure this is a good idea, though. It feels like it'd just create a mess.

@jgaskins
Copy link
Owner Author

jgaskins commented Dec 5, 2012

Serialization extracted in 307812f. Deserialization is up next.

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