Extends this class in order to define a closure that can be used with a nicer and more readable syntax as it follows:
withTransaction(); {
of(this).doSomething();
}
To achieve this result the withTransaction() should be defined as:
public void withTransaction() {
delayedClosure(new DelayedClosure<Void>() {
public Void doWithClosure(Closure closure) {
beginTransaction();
closure.apply();
commit();
return null;
}
});
}
It is also possible to get a result from the method that uses this kind of closure by reading it from the getClosureResult() method