groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yaro <>
Subject Re: Bypassing local variables in a closure
Date Sat, 18 Jul 2015 02:05:40 GMT
interestingly, I managed to do it through some obscure way:
in someMethod:

closure.class.declaredFields*.name.findAll { it ==~ /^[^_$].+/ }.each {
      actions.@"$it"= new Reference(&myValidatorMethod)

which finds all local variables within the closure and changes their binding 
to my validator method, so any calls that match the local variables names
will get handled by validator and anything else - by methodMissing.

Anybody can suggest a better solution?

View this message in context:
Sent from the Groovy Users mailing list archive at

View raw message