Thanks for the feedback guys. Another related Q: The user needs to require the namespace that those defmethods are defined in for the multi to know about it. Presumably each defmethods will be in individual files, meaning the user has to require all those files for the migration tool to work. Is there a cleaner way of make sure that the defmulti knows about those methods?
On Thursday, May 14, 2015 at 7:56:12 PM UTC-4, Jason Marmon wrote: > > I'm working on a tool to orchestrate the migration from mongodb to > datomic, and i'm looking for a bit of design feedback as i'm new to > clojure. > > > The user needs to provide functions that transform mongodb documents into > datomic txes. Do y'all prefer the top or bottom style, or think there's a > different way to implement this design that might be better? > 12345678910111213141516171819 > > ;; Multimethod for transforming data based on the name of the source mongodb > collection > (defmulti transform identity) > > (defmethod transform "events" [data] > ;; do something with data > ) > > (defmethod transform "users" [data] > ;; do something with data > ) > > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; > > (defprotocol Collection-Transformer > (transform [mongo-db document])) > > (def user-transformer > (reify Collection-Transformer > (transform [m d] "do stuff"))) > > -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.