lib/ruote/exp/fe_cursor.rb in ruote-2.2.0 vs lib/ruote/exp/fe_cursor.rb in ruote-2.3.0
- old
+ new
@@ -1,7 +1,7 @@
#--
-# Copyright (c) 2005-2011, John Mettraux, jmettraux@gmail.com
+# Copyright (c) 2005-2012, John Mettraux, jmettraux@gmail.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@@ -64,10 +64,16 @@
# reviewer
# rewind :if => '${f:not_ok}'
# publisher
# end
#
+ # === reset
+ #
+ # Whereas 'rewind' places the cursor back to the initial step with the current
+ # workitem, 'reset' will rewind it and start again but with the workitem
+ # as it was when it reached the cursor/repeat.
+ #
# === stop, over & break
#
# Exits the cursor.
#
# cursor do
@@ -260,20 +266,24 @@
com, arg = get_command(workitem)
return reply_to_parent(workitem) if com == 'break'
case com
- when 'rewind', 'continue' then position = 0
+ when 'rewind', 'continue', 'reset' then position = 0
when 'skip' then position += arg
when 'jump' then position = jump_to(workitem, position, arg)
end
position = 0 if position >= tree_children.size && is_loop?
if position < tree_children.size
+
+ workitem = h.applied_workitem if com == 'reset'
apply_child(position, workitem)
+
else
+
reply_to_parent(workitem)
end
end
# Will return true if this instance is about a 'loop' or a 'repeat'.
@@ -296,11 +306,11 @@
exp_name = c[0]
ref = c[1]['ref']
tag = c[1]['tag']
- ref = @context.dollar_sub.s(ref, self, workitem) if ref
- tag = @context.dollar_sub.s(tag, self, workitem) if tag
+ ref = dsub(ref, workitem) if ref
+ tag = dsub(tag, workitem) if tag
next if exp_name != arg && ref != arg && tag != arg
pos = i
break