How builders work
Earlier, when we looked at the MarkupBuilder
code, the unfamiliar syntax must have seemed strange. Now that we have an understanding of how the MOP and pretended methods work, let's take a quick look again at some builder code and see if we can figure out what might be happening. MarkupBuilder
is derived from the BuilderSupport
class. When describing how MarkupBuilder
works, I won't make a distinction between BuilderSupport
and MarkupBuilder
. Most of the mechanisms described here are in fact implemented by BuilderSupport
and are shared with other Builder
classes:
def customers = builder.customers { customer(id:1001) { name(firstName:"Fred",surname:"Flintstone") address(street:"1 Rock Road",city:"Bedrock") } customer(id:1002) { name(firstName:"Barney",surname:"Rubble") address(street:"2 Rock Road",city:"Bedrock") } }
No matter how far you look in the documentation for MarkupBuilder
, you won't find anything about it having a...