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

Move defining fields to adapters #568

Merged
merged 4 commits into from
Jul 4, 2014

Conversation

arnvald
Copy link
Collaborator

@arnvald arnvald commented Jul 1, 2014

Currently in every single submodule that requires additional fields in model,
we've got a conditional block for each ORM. To reduce code duplication,
a define_field method was added to each of ORM adapters. Now we can run it no
matter what ORM is used, and adapter will handle it.

This is the first step to extracting adapters. Next one will be to move defining callbacks to adapters.

cc @kirs

Update

Ok, I've already moved defining callbacks, too, and I've added it to this PR.

arnvald added 2 commits July 2, 2014 01:31
Currently in every single submodule that requires additional fields in model,
we've got a conditional block for each ORM. To reduce code duplication,
a `define_field` method was added to each of ORM adapters. Now we can run it no
matter what ORM is used, and adapter will handle it.
Just like in case of fields, defining callbacks should be done the same way for
all adapters. This version includes basic definition that handles all currently
used in Sorcery cases
@kirs
Copy link
Collaborator

kirs commented Jul 2, 2014

Looks good!

I would rename define_field method to define_sorcery_field because define_field may be used by ORM or end developer.

@arnvald
Copy link
Collaborator Author

arnvald commented Jul 2, 2014

Good point!

I still need to fix some issues with DataMapper, I hope to finish it tomorrow.

arnvald added 2 commits July 5, 2014 00:41
As pointed by @kirs, these names are quite general. To avoid potential problems
they were renamed to define_sorcery_field and define_sorcery_callback
arnvald added a commit that referenced this pull request Jul 4, 2014
@arnvald arnvald merged commit 46d890f into NoamB:master Jul 4, 2014
@arnvald arnvald deleted the extract_define_field_method branch July 4, 2014 17:05
@arnvald
Copy link
Collaborator Author

arnvald commented Jul 4, 2014

Done! It took me a while, but it looks better now. I'm already working on decoupling the rest of code from ORMs

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

Successfully merging this pull request may close these issues.

2 participants