On Wed, Sep 9, 2009 at 12:38 AM, Gonzalo<[email protected]> wrote: > > I'm trying to use the _if :test => "" construct in a workflow. I > succeeded with just one comparison: > > _if :test => "${color} == "green" do > [...] > > > But if I try to nest several comparisons with boolean operators (and, > or...) it doesn't work: > > _if :test => "${key0} == ${fields:key0} and > ${key1} == ${fields:key1} and > ${key2} == ${fields:key2} and > ${key3} == ${fields:key3}" do > [...] > > > Is it supported? Maybe I'm using a wrong syntax or there's a better > way to do this stuff.
Hello Gonzalo, I've added a test to ruote 0.9 that covers your question : http://github.com/jmettraux/ruote/blob/b76e754e7c2d12f28b515be025b733d3e6e169a8/test/functional/eft_4_if.rb#L95-143 Note the use of the :rtest attribute instead of :test, ruby evaluation is performed on the value of the :rtest attribute thus more complicated checks are performed. In this evaluated Ruby code, the workitem is bound under "wi" and the expression under "fe", it's thus OK to write wi.field_name or wi.fields['field_name'] and fe.lookup_variable("v0"). It should be said that it's maybe better to put big decision logic into dedicated participants and then have light "if" nodes. sequence do participant "decide" _if :test => "${f:take_umbrella}" do participant "rainy_day" participant "sunny_day" end end #... engine.register_participant :decide do |workitem| workitem.fields['take_umbrella'] = case workitem.fields['weather'] when "rain" then true when "cloudy" then true else false end end Of course, it all depends on your use case, but it's good to have decision logic decoupled from execution logic. Best regards, -- John Mettraux - http://jmettraux.wordpress.com --~--~---------~--~----~------------~-------~--~----~ you received this message because you are subscribed to the "ruote users" group. to post : send email to [email protected] to unsubscribe : send email to [email protected] more options : http://groups.google.com/group/openwferu-users?hl=en -~----------~----~----~----~------~----~------~--~---
