On Thu, Jul 22, 2010 at 09:52:29AM +0900, John Mettraux wrote:
> 
> I've tried to cook up a decent re_apply example, less trivial than the one 
> found in the tests :
> 
>   
> http://github.com/jmettraux/ruote/blob/ruote2.1/test/functional/ft_14_re_apply.rb#L197-221
> 
> but I encountered an issue while cooking up :
> 
>   http://gist.github.com/485410
> 
> The issue is also present with the current [stable] 2.1.10 gem.
> 
> Please give me some time to fix that.

Doh, wrote too fast.

It actually works :

  
http://github.com/jmettraux/ruote/blob/ruote2.1/test/functional/ft_14_re_apply.rb#L197-221

---8<---
require 'rubygems'
require 'ruote'

engine = Ruote::Engine.new(Ruote::Worker.new(Ruote::HashStorage.new))

pdef = Ruote.define do
  sequence do
    alpha
    bravo
    zebulon
  end
end

class ThisParticipant
  include Ruote::LocalParticipant
  def consume (workitem)
    puts "* #{workitem.participant_name}"
    reply_to_engine(workitem)
  end
end
class ThatParticipant
  include Ruote::LocalParticipant
  def consume (workitem)
    puts ". #{workitem.participant_name}"
    # no reply to engine
  end
  def cancel (fei, flavour)
    # ok, let pass
  end
  def do_not_thread; true; end
end

engine.register_participant 'alpha', ThisParticipant
engine.register_participant 'bravo', ThisParticipant
engine.register_participant 'charlie', ThisParticipant
engine.register_participant 'zebulon', ThatParticipant

#engine.context.logger.noisy = true

wfid = engine.launch(pdef)

engine.wait_for(:zebulon)

ps = engine.process(wfid)

sequence = ps.expressions.find { |fexp| fexp.fei.expid == '0_0' }

puts "re_applying..."

#engine.re_apply(sequence.fei, :tree => Ruote.to_tree do
engine.re_apply(sequence.fei, 'tree' => Ruote.to_tree do
  sequence do
    charlie
    bravo
    alpha
  end
end)

engine.wait_for(wfid)
--->8---

outputs :

---8<---
* alpha
* bravo
. zebulon
re_applying...
* charlie
* bravo
* alpha
--->8---


Ruote.define {} returns a definition, while Ruote.to_tree {} returns only the 
sequence, without the define wrapping.


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

Reply via email to