As shown in the documentation on defprotocol, you need to define a struct
in the D4.Activity module, and then pass a %D4.Activity{} struct to the
protocol function. As it is you're just passing in a module name which is
an Atom, and there is no protocol implementation for atoms.
On Monday, August 1, 2016 at 2:54:29 PM UTC-4, Maximiliano Guzenski wrote:
>
> Hi,
> I'm trying a simple to implement defprotocol/defimpl but I recevei always
> a error:
> ps.: Activity is a Ector module, I using phoenix
>
> defprotocol D4.Policy do
> def scoped(a, query, conn)
> end
>
> defimpl D4.Policy, for: D4.Activity do
> def scoped(a, query, conn) do
> IO.puts "hi"
> end
> end
>
> D4.Policy.scoped(D4.Activity, 1, 2)
>
> error -->
>
> ** (Protocol.UndefinedError) protocol D4.Policy not implemented for
> D4.Activity
>
> (d4) web/lib/policy.ex:1: D4.Policy.impl_for!/1
>
> (d4) web/lib/policy.ex:3: D4.Policy.scoped/3
>
>
--
You received this message because you are subscribed to the Google Groups
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elixir-lang-core/10a5782e-a154-4ffd-82cd-119d58709d61%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.