lib/ruote/exp/fe_set.rb in ruote-2.1.11 vs lib/ruote/exp/fe_set.rb in ruote-2.2.0

- old
+ new

@@ -1,7 +1,7 @@ #-- -# Copyright (c) 2005-2010, John Mettraux, jmettraux@gmail.com +# Copyright (c) 2005-2011, 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 @@ -83,13 +83,22 @@ # set 'f' => 'val0' # set 'v:v' => 'val1' # set 'f_${v:v}' => 'val2' # end # + # == set and rset + # + # Some gems (Sinatra) for example may provide a set method that hides calls + # to set when building process definitions (see http://groups.google.com/group/openwferu-users/browse_thread/thread/9ac606e30ada686e) + # + # A workaround is to write 'rset' instead of 'set'. + # + # rset 'customer' => 'Jeff' + # class SetExpression < FlowExpression - names :set, :unset + names :rset, :set, :unset def apply opts = { :escape => attribute(:escape) } @@ -115,37 +124,37 @@ end reply_to_parent(h.applied_workitem) end - def reply (workitem) + def reply(workitem) # never called end protected - def set_v (key, value) + def set_v(key, value) if name == 'unset' unset_variable(key) else set_variable(key, value) end end - def set_f (key, value) + def set_f(key, value) if name == 'unset' h.applied_workitem['fields'].delete(key) else Ruote.set(h.applied_workitem['fields'], key, value) end end - PREFIX_REGEX = /^([^:]+):(.+)$/ unless defined?(PREFIX_REGEX) + PREFIX_REGEX = /^([^:]+):(.+)$/ #unless defined?(PREFIX_REGEX) - def set_vf (key, value) + def set_vf(key, value) field = true if m = PREFIX_REGEX.match(key) field = m[1][0, 1] == 'f'