Created
March 31, 2017 23:22
-
-
Save BenMorganIO/d541d086dd8043d7d26c8db05e585a23 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
defmodule Ryal.PaymentMethod do | |
schema "ryal_payment_methods" do | |
field :type, :string | |
embeds_one :data, modularize_field(:type) # :p | |
end | |
end | |
# or, can I do: | |
schema "ryal_payment_methods" do | |
field :type, :string | |
embeds_one :data, Ryal.PaymentMethod.CreditCard | |
embeds_one :data, Ryal.PaymentMethod.Bitcoin | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Did you ever find a decent way to do this? Found this gist through the IRC logs and am trying to figure out how to do the same thing (https://botbot.me/freenode/elixir-lang/2017-03-31/?msg=40248917&page=7)