Curried Closures XML Markup

After having played with Groovy closures for a bit I thought it would be an excellent way to complement my REST webservice while rendering the XML for one of my domain classes. While I was trying not to duplicate to much code by using Groovy Closures, I ran into a few bumps. Here’s the short version.

At first I had this construction for my BookController with ony a book action:

	def book = {
		if(params.id && Book.exists(params.id)) {
			def b = Book.get(params.id)
			render b as XML
		}
		else {
			def all = Book.list()
			render b as XML
		}
	}

Continue reading “Curried Closures XML Markup”