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

Use multimethods for custom hydration functions #31

Open
camsaul opened this issue Jan 9, 2018 · 2 comments
Open

Use multimethods for custom hydration functions #31

camsaul opened this issue Jan 9, 2018 · 2 comments

Comments

@camsaul
Copy link
Member

camsaul commented Jan 9, 2018

Instead of tagging them with metadata it would be better if we could make them multimethods that dispatch off of the model as well as the key they are hydrating. That way different methods could be used to hydrate the same key for instances of different models. The approach also seems a little cleaner than having hydrate look through all namespaces for functions with matching metadata

There are two things that might make this tricky:

  • The difference between single hydration and batched hydration functions would have to be addressed somehow (perhaps with two multimethods?)
  • This change would require reworking things a bit for people using the library
@camsaul camsaul changed the title Make custom hydration functions multimethods Use multimethods for custom hydration functions Jan 9, 2018
@camsaul
Copy link
Member Author

camsaul commented Jan 16, 2019

I'm actually of the opinion that everything (including things like pre-insert!) should be implemented with multimethods instead of protocols. That would be a big breaking change, however.

@tlrobinson
Copy link

Is there a workaround for "different methods could be used to hydrate the same key for instances of different models"?

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

No branches or pull requests

2 participants