|
NAMEWorkflow::Condition::Evaluate - Inline condition that evaluates perl code for truth VERSIONThis documentation describes version 2.05 of this package SYNOPSIS <state name="foo">
<action name="foo action">
<condition test="$context->{foo} =~ /^Pita chips$/" />
DESCRIPTIONIf you've got a simple test you can use Perl code inline instead of specifying a condition class. We differentiate by the 'test' attribute -- if it's present we assume it's Perl code to be evaluated. While it's easy to abuse something like this with: <condition>
<test><![CDATA[
if ( $context->{foo} =~ /^Pita (chips|snacks|bread)$/" ) {
return $context->{bar} eq 'hummus';
}
else { ... }
]]>
</test>
</condition>
It should provide a good balance. OBJECT METHODSnew( \%params ) One of the "\%params" should be 'test', which contains the text to evaluate for truth. evaluate( $wf ) Evaluate the text passed into the constructor: if the evaluation returns a true value then the condition passes; if it throws an exception or returns a false value, the condition fails. We use Safe to provide a restricted compartment in which we evaluate the text. This should prevent any sneaky bastards from doing something like: <state...>
<action...>
<condition test="system( 'rm -rf /' )" />
The text has access to one variable, for the moment:
SEE ALSO
COPYRIGHTCopyright (c) 2004-2021 Chris Winters. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Please see the LICENSE AUTHORSPlease see Workflow
|