Skip to content

Commit

Permalink
Explicitly extend IPersistentMap [fixes #57]
Browse files Browse the repository at this point in the history
This should prevent clojure maps from being dispatched as Seqables on
occasion.
  • Loading branch information
tobias committed Oct 21, 2013
1 parent d7b50e0 commit d2e0c79
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion api/src/main/clojure/vertx/utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
(:require [clojure.string :as s]
[clojure.data.json :as json])
(:import [org.vertx.java.core.json JsonArray JsonElement JsonObject]
[clojure.lang BigInt Ratio Seqable]
[clojure.lang BigInt IPersistentMap Ratio Seqable]
[java.util Map UUID]
java.math.BigDecimal))

Expand All @@ -33,6 +33,12 @@
(encode [data] (double data))
BigInt
(encode [data] (long data))
;; clojure maps are Maps and Seqables, and sometimes the Seqable
;; version gets called for a them. Let's explicitly extend
;; the clojure map interface to prevent that.
IPersistentMap
(encode [data]
(JsonObject. (json/write-str data)))
Map
(encode [data]
(JsonObject. (json/write-str data)))
Expand Down

0 comments on commit d2e0c79

Please sign in to comment.