[#148] [Fix] tools/freeze should use *freeze-opts* even for unwrapped vals
This commit is contained in:
parent
c6948ea40d
commit
9e69a284e1
1 changed files with 9 additions and 8 deletions
|
|
@ -28,19 +28,20 @@
|
||||||
"Like `nippy/freeze` but merges opts from *freeze-opts*, `wrap-for-freezing`."
|
"Like `nippy/freeze` but merges opts from *freeze-opts*, `wrap-for-freezing`."
|
||||||
([x ] (freeze x nil))
|
([x ] (freeze x nil))
|
||||||
([x default-opts]
|
([x default-opts]
|
||||||
(let [;; For back compatibility:
|
(let [default-opts (get default-opts :default-opts default-opts) ; For back compatibility
|
||||||
default-opts (get default-opts :default-opts default-opts)]
|
merged-opts (conj (or default-opts {}) *freeze-opts*)]
|
||||||
|
|
||||||
(if (instance? WrappedForFreezing x)
|
(if (instance? WrappedForFreezing x)
|
||||||
(let [^WrappedForFreezing x x]
|
(let [^WrappedForFreezing x x]
|
||||||
(nippy/freeze (.-val x) (merge default-opts *freeze-opts* (.-opts x))))
|
(nippy/freeze (.-val x) (conj merged-opts (.-opts x))))
|
||||||
(nippy/freeze x default-opts)))))
|
(nippy/freeze x merged-opts)))))
|
||||||
|
|
||||||
(defn thaw
|
(defn thaw
|
||||||
"Like `nippy/thaw` but merges opts from `*thaw-opts*`."
|
"Like `nippy/thaw` but merges opts from `*thaw-opts*`."
|
||||||
([ba ] (thaw ba nil))
|
([ba ] (thaw ba nil))
|
||||||
([ba default-opts]
|
([ba default-opts]
|
||||||
(let [;; For back compatibility:
|
(let [default-opts (get default-opts :default-opts default-opts) ; For back compatibility
|
||||||
default-opts (get default-opts :default-opts default-opts)]
|
merged-opts (conj (or default-opts {}) *thaw-opts*)]
|
||||||
(nippy/thaw ba (merge default-opts *thaw-opts*)))))
|
(nippy/thaw ba merged-opts))))
|
||||||
|
|
||||||
(comment (thaw (freeze (wrap-for-freezing "wrapped"))))
|
(comment (thaw (freeze (wrap-for-freezing "wrapped"))))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue