Fork me on GitHub
#liberator
<
2017-05-10
>
owen15:05:12

I'm trying to extend liberator:

(extend-protocol Representation
  clojure.lang.PersistentHashSet
  (as-response [this context]
    {:body "asdf"}))

owen15:05:29

but I'm still seeing: No implementation of method: :as-response of protocol: #'liberator.representation/Representation found for class: clojure.lang.PersistentHashSet

owen15:05:56

I can't see what's different from the examples in liberator.representation

ordnungswidrig15:05:29

That’s weird. Try to call as-response on an instance of HashSet directly. Does that work?

owen16:05:09

(as-response #{:a 1} {:representation {:media-type "application/json"}})

owen16:05:25

#error {
 :cause "No implementation of method: :as-response of protocol: #'liberator.representation/Representation found for class: clojure.lang.PersistentHashSet"  

ordnungswidrig17:05:03

I will try to reproduce. Independent of the actual protocol that should work.

owen17:05:31

hmm this does appear to be [liberator "0.12.0"] not sure if this would've been fixed between versions

ordnungswidrig17:05:42

Don't quite understand. Is it broken in 0.12 for you but ok in a different revision?

owen17:05:27

no was just giving context

owen17:05:30

hmm, it's fine with wrapping the set in a map: (as-response {:x #{:a 1}} {:representation {:media-type "application/json"}})

ordnungswidrig17:05:05

That is a map which is supported by liberator out of the box. I suspect that somehow the extend-protocol is not executed.

ordnungswidrig19:05:56

@owen there’s something wrong with your protocol extension. Make sure the namespace where the extension is called is required and loaded. It works for me as expected:

owen19:05:30

hmm odd, thanks for verifying

ordnungswidrig19:05:31

This is on latest master but I don’t think it would make a difference on 0.12.0

ordnungswidrig19:05:14

Tested in 0.12.0 an works locally. I’m pretty sure your call to extend-protocol is not executed.