liberator 2017-05-10

@owen has joined the channel

I'm trying to extend liberator:

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

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

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

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

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

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

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

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

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

no was just giving context

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

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

@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:

hmm odd, thanks for verifying

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

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