(wrap-rule rule {what-fn :what, when-fn :when, then-fn :then, then-finally-fn :then-finally})
Wraps the functions of a rule so they can be conveniently intercepted
for debugging or other purposes.
See the README section "Debugging".
Source
(defn
wrap-rule
"Wraps the functions of a rule so they can be conveniently intercepted\n for debugging or other purposes.\n See the README section \"Debugging\"."
[rule
{what-fn :what,
when-fn :when,
then-fn :then,
then-finally-fn :then-finally}]
(cond->
(assoc rule :what-fn what-fn)
(and (:when-fn rule) when-fn)
(update
:when-fn
(fn wrap-when [f] (fn [session match] (when-fn f session match))))
(and (:then-fn rule) then-fn)
(update
:then-fn
(fn wrap-then [f] (fn [session match] (then-fn f session match))))
(and (:then-finally-fn rule) then-finally-fn)
(update
:then-finally-fn
(fn
wrap-then-finally
[f]
(fn [session] (then-finally-fn f session))))))