Yes, my mistake... struct(D4.Activity) resolved it... thanks !

On Monday, August 1, 2016 at 4:01:59 PM UTC-3, Ben Wilson wrote:
>
> 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/cc4d0dd6-764c-4b83-8db7-5acc4dd58bf1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to