diff --git a/README.md b/README.md index 79e645e..61cc33e 100644 --- a/README.md +++ b/README.md @@ -246,7 +246,7 @@ You may use `PolymorphicEmbed.HTML.Component.polymorphic_embed_inputs_for/1` whe ``` -### Get the type of a polymorphic embed +### Get the type and module of a polymorphic embed Sometimes you need to serialize the polymorphic embed and, once in the front-end, need to distinguish them. `PolymorphicEmbed.get_polymorphic_type/3` returns the type of the polymorphic embed: @@ -255,6 +255,12 @@ Sometimes you need to serialize the polymorphic embed and, once in the front-end PolymorphicEmbed.get_polymorphic_type(Reminder, :channel, SMS) == :sms ``` +To get the module for a specific type, use: + +```elixir +PolymorphicEmbed.get_polymorphic_module(Reminder, :channel, :sms) == SMS +``` + ### `traverse_errors/2` The function `Ecto.changeset.traverse_errors/2` won't include the errors of polymorphic embeds. You may instead use `PolymorphicEmbed.traverse_errors/2` when working with polymorphic embeds.