Skip to content

Instantly share code, notes, and snippets.

@noeticpenguin
Created October 30, 2014 17:24
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save noeticpenguin/cd457c5b969b48b1f28a to your computer and use it in GitHub Desktop.
Save noeticpenguin/cd457c5b969b48b1f28a to your computer and use it in GitHub Desktop.
public class Dynamic {
public class IntentionalException extends Exception{}
public static boolean eval(String toEval){
boolean result = false;
if(!toEval.startsWith('if')) {
toEval = 'if(' + toEval + ') {throw new Dynamic.IntentionalException(\'true\');} else {throw new Dynamic.IntentionalException(\'false\');}';
}
ToolingAPI x = new ToolingAPI();
try{
ToolingAPI.ExecuteAnonymousResult toolingResult = x.executeAnonymousUnencoded(toEval);
} catch (IntentionalException ie) {
result = (ie.getMessage() == 'true') ? True : False;
}
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment