| Author |
Modular Closures for Builders (FactoryBuilderSupport)
|
John Dee
Greenhorn
Joined: May 13, 2010
Posts: 3
|
|
The following is an attempt to modularize my DSL files because
there is a nested closure that is identically defined in
many of these DSL files.
Current (working) Non-Modular Implementation
JAVA CODE:
patient.groovy
The above works, but the problem is that the entire closure drug(){...}
is used in many other DSL files.
So, what I would like to do is pull the drug(){...} closure out of patient.groovy and put it
into a new drugs.groovy. The following is what I modified the above to in order to modularize the
drug closure, but I'm not understanding part of it.
Modified (broken) Modular Implementation
Modified Java Code:
New drugs.groovy
Modified patient.groovy
I think things are breaking down in the new drugs() {...} closure. drugClosure is defined in
a separate file and I'm having a heck of a time trying to find information that explains how to
include/reference/inject that into patient {...}
Any help would be much appreciated.
Thanks,
John
|
 |
John Dee
Greenhorn
Joined: May 13, 2010
Posts: 3
|
|
I found the solution:
The the builder class needs a new method I named as 'include(Closure c, Object args)' method within the builder.
BUILDER Class:
Modified patient.groovy
|
 |
 |
|
|
subject: Modular Closures for Builders (FactoryBuilderSupport)
|
|
|