lib/ruote/id/wfid_generator.rb in ruote-2.1.11 vs lib/ruote/id/wfid_generator.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 @@ -25,11 +25,11 @@ module Ruote class WfidGenerator - def initialize (context) + def initialize(context) @context = context @last = @context.storage.get('variables', 'last_wfid') || @@ -52,17 +52,24 @@ raw = Time.now.utc raw = raw + 0.01 while raw.to_f <= lraw @last['raw'] = raw.to_f - last = @context.storage.put(@last) + last = @context.storage.put(@last, :update_rev => true) - if last + if last == true # + # 'last' is gone, have to put new one + @last.delete('_rev') + get_raw + + elsif last + # # put failed, have to re-ask # @last = last get_raw + else # # put successful, we can build a new wfid # raw