Hi all,
What is the idiomatic way to decorate a nested graph with multiple
decorators? Let me explain:
I have a list of graphs:
[
{ :id 1
propertyA: {:customer 1 :name whatever :date (Date.)}
propertyB: {:customer 1 :created (Date.) :someOtherProperty 13}
}
]
After creating this graph (and only after, not before), I can now retrieve
all the customers I need and create map (using group-by) of customerId:
customer. I also want to replace all the Dates to millisecondsSinceEpoch.
Just for fun I also want to decorate all instances of propertyA (but not
propertyB) with an extra property.
Some contraints: I cannot decorate each item at the time it is being
loaded. For example, I need to load the entire graph to identify which
customers are needed, which I can then load in one batch. I can't load all
the customers because there are a gazillion of them.
What I am currently doing is a wonderfully complex combination of defining
each decorator as a separate function and then using nested fors.
Something like:
(defn transform [graphs]
(let [
customers (load-customers-by-id graphs)
]
(defn resolve-customer [g] (assoc g :customer ((:customer g) customers)
)
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en