lib/ruote/part/storage_participant.rb in ruote-2.3.0.1 vs lib/ruote/part/storage_participant.rb in ruote-2.3.0.2
- old
+ new
@@ -1,7 +1,7 @@
#--
-# Copyright (c) 2005-2012, John Mettraux, jmettraux@gmail.com
+# Copyright (c) 2005-2013, 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
@@ -102,9 +102,26 @@
def update(workitem)
r = @context.storage.put(workitem.h)
r.is_a?(Hash) ? Ruote::Workitem.new(r) : r
+ end
+
+ # Added for https://groups.google.com/forum/?fromgroups#!topic/openwferu-users/5bpV2yfKwM0
+ #
+ # Makes sure the workitem get saved to the storage. Fails if the workitem
+ # is already gone.
+ # Returns nil in case of success.
+ #
+ def do_update(workitem=@workitem)
+
+ r = update(workitem)
+
+ fail ArgumentError.new("workitem is gone") if r == true
+ return nil if r.nil?
+
+ r.h['fields'] = workitem.fields
+ do_update(r)
end
# Removes the document/workitem from the storage.
#
# Warning: this method is called by the engine (worker), i.e. not by you.