Skip to content

Conversation

@bceskavich
Copy link
Contributor

Rather than define a bunch of __field__/1 functions on the caller
module as the field/3 macro is invoked, we only collect field
definition metadata in an accumulator attribute. Later, we serialize
the field definitions together into a formatted map on demand via
__schema__(:fields).

This change will allow users to define fields on their schemas in
for comprehensions or maps, without any compiler warnings about
unmatchable function heads.

Rather than define a bunch of `__field__/1` functions on the caller
module as the `field/3` macro is invoked, we only collect field
definition metadata in an accumulator attribute. Later, we serialize
the field definitions together into a formatted map on demand via
`__schema__(:fields)`.

This change will allow users to define fields on their schemas in
for comprehensions or maps, without any compiler warnings about
unmatchable function heads.
@bceskavich bceskavich requested a review from sjkaliski May 6, 2019 13:42
@bceskavich bceskavich merged commit 7888a08 into develop May 6, 2019
@bceskavich bceskavich deleted the bc-schema-field-macro-refactor branch May 6, 2019 17:48
bceskavich added a commit that referenced this pull request May 6, 2019
Rather than define a bunch of `__field__/1` functions on the caller
module as the `field/3` macro is invoked, we only collect field
definition metadata in an accumulator attribute. Later, we serialize
the field definitions together into a formatted map on demand via
`__schema__(:fields)`.

This change will allow users to define fields on their schemas in
for comprehensions or maps, without any compiler warnings about
unmatchable function heads.
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