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

Cast all values before insert #149

Merged
merged 1 commit into from
Jul 30, 2016
Merged

Cast all values before insert #149

merged 1 commit into from
Jul 30, 2016

Conversation

jsteiner
Copy link
Contributor

Casts each field based on the type declared in the schema. Recursively casts built associations.

I added the ability to cast bare maps, but left it separate. After thinking on it some more, I'm not convinced it should be a feature of ExMachina. I couldn't think of a time when you would be building a record with ExMachina, but would want to pass an association in as a bare map. Curious if anybody else has some use cases for that.

|> cast_fields(struct)
end

defp cast_fields(fields, struct) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on naming this cast_all_fields or something like that? I didn't notice the s at the end and thought the next function was the same, but with different patterns. Changing the name might help to clarify that a bit

@paulcsmith
Copy link
Contributor

A few questions/comments. Overall this looks awesome. Can't wait to use this. Will be so handy with dates generated with GoodTimes!

@jsteiner jsteiner force-pushed the js-cast branch 3 times, most recently from b3e8ad8 to 7801a86 Compare July 30, 2016 17:40
Casts each field based on the type declared in the schema. Recursively
casts built associations.
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.

3 participants