technomancy / robert-hooke

Hooke your Clojure functions!
Other
359 stars 25 forks source link

clear-hooks function throws exception when no hooks exist for target var #4

Closed pauldorman closed 12 years ago

pauldorman commented 12 years ago

The subject says it all. The modified implementation below works for me.

(defn clear-hooks
  "Remove all hooks from target-var if present."
  [target-var]
  (when (:robert.hooke/hook (meta @target-var))
    (swap! (:robert.hooke/hook (meta @target-var)) empty)
    (when (empty? @(:robert.hooke/hook (meta @target-var)))
      (clear-hook-mechanism target-var))))
technomancy commented 12 years ago

This should be fixed by the latest pull request.