-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Ecto.Strategy to use Ecto.Schema reflections (#248)
Summary ======= `Ecto.Schema` has a `__schema__/1` function that allows us to instrospect which fields are non-virtual, which are embeds, and which are associations. We already make use of this `__schema__` function for determining associations and embeds, but the code seemed somewhat complicated in that when we cast fields, we had to know to skip associations and embeds by checking each fields type. By using `__schema__(:fields)` and `__schema__(:embeds)` we are able to cast fields first, then embeds, and finally associations. This has the advantage of allowing us to untangle associations and embeds code which, although is somewhat similar, does not overlap completely (there are more conditions to check when casting associations).
- Loading branch information
Showing
1 changed file
with
60 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters