lib/ruote/exp/fe_save.rb in ruote-2.2.0 vs lib/ruote/exp/fe_save.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 @@ -21,22 +21,25 @@ # # Made in Japan. #++ - module Ruote::Exp # # Saves the current workitem fields into a variable or into a field. # # save :to_field => 'old_workitem' + # # or + # save :to => 'f:old_workitem' # # # # saves a copy of the fields of the current workitem into itself, # # in the field named 'old_workitem' # # save :to_variable => '/wix' + # # or + # save :to => 'v:/wix' # # # # saves a copy of the current workitem in the varialbe 'wix' at # # the root of the process # # See also the 'restore' expression (Ruote::Exp::RestoreExpression). @@ -45,27 +48,17 @@ names :save def apply - tk = - has_attribute(*%w[ v var variable ].map { |k| "to_#{k}" }) || - has_attribute(*%w[ f fld field ].map { |k| "to_#{k}" }) + to_v, to_f = determine_tos - return reply_to_parent(h.applied_workitem) unless tk - - key = attribute(tk) - - if tk.match(/^to_v/) - - set_variable(key, h.applied_workitem['fields']) - - elsif tk.match(/^to_f/) - - Ruote.set( - h.applied_workitem['fields'], - key, - Ruote.fulldup(h.applied_workitem['fields'])) + if to_v + set_variable(to_v, h.applied_workitem['fields']) + elsif to_f + set_f(to_f, Ruote.fulldup(h.applied_workitem['fields'])) + #else + # do nothing end reply_to_parent(h.applied_workitem) end