Created
June 17, 2011 02:47
-
-
Save bostonaholic/1030763 to your computer and use it in GitHub Desktop.
meta programming in groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def isDetailCancellableWithDelegate = { | |
delegate.status != "INVOICED" || billingService.isCancellable(delegate.invoice) | |
} | |
def theMetaProgrammingWay = { | |
def listOfObjects = detailService.findAll() | |
listOfObjects.each { | |
it.metaClass.isCancellable = isDetailCancellableWithDelegate | |
} | |
listOfObjects | |
} | |
/*****************************************************/ | |
def isDetailCancellableNormal(def it) { | |
it.status != "INVOICED" || billingService.isCancellable(it.invoice) | |
} | |
def the_Normal_Way = { | |
def listOfObjects = detailService.findAll() | |
def listOfMaps = [] | |
listOfObjects.each { | |
def props = it.properties | |
props.isCancellable = isDetailCancellableNormal(props) | |
listOfMaps.add props | |
} | |
listOfMaps | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment