Hi, I only needed the 'annotations' to work with structmaps and records (data structures I use to define my domain model), therefore ignored other data structures:
(defn cut-key [it] (if (keyword? it) it (keyword (str it)))) (def decorations (atom {})) ; Argument "decor" should be a structmap, that serves as the metadata of ; the class/type from argument "key". (defn with-decor [decor key] (if (var? key) (swap! decorations assoc (cut-key @key) decor) (swap! decorations assoc (cut-key key) decor))) (defn decor [key definition] ((cut-key key) ((cut-key definition) @decorations))) (with-decor {:type "Something"} (defrecord Something [id name description])) Unit tests: (deftest decor-should-return-correct-metadata-of-record (is (= "Something" (decor :type Something)))) ; (decor ...) must be updated to check and handle if passed in value is a "var" (with-decor {:type "SomethingElse"} (defstruct SomethingElse :id :name :description)) (deftest decor-should-return-correct-metadata-of-structmap (is (= "SomethingElse" (decor :type SomethingElse)))) What do you think? Jacques On Wednesday, May 16, 2012 3:54:14 PM UTC+2, Tim Visher wrote: > > On Tue, May 15, 2012 at 12:11 PM, JDuPreez wrote: > > Maybe I should post my solution to this problem here? > > Sounds like a plan. :) > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en