Parent

Class/Module Index [+]

Quicksearch

Ruote::WfidGenerator

Public Class Methods

new(context) click to toggle source
# File lib/ruote/id/wfid_generator.rb, line 30
def initialize (context)

  @context = context

  @last =
    @context.storage.get('variables', 'last_wfid') ||
    { 'type' => 'variables', '_id' => 'last_wfid', 'raw' => Time.now.utc.to_f }
end

Public Instance Methods

generate() click to toggle source
# File lib/ruote/id/wfid_generator.rb, line 39
def generate

  raw = get_raw

  "#{raw.strftime('%Y%m%d%H%M%S')}-#{raw.usec}"
end

Protected Instance Methods

get_raw() click to toggle source
# File lib/ruote/id/wfid_generator.rb, line 48
def get_raw

  lraw = @last['raw'] + 0.01

  raw = Time.now.utc
  raw = raw + 0.01 while raw.to_f <= lraw

  @last['raw'] = raw.to_f

  last = @context.storage.put(@last)

  if last
    #
    # put failed, have to re-ask
    #
    @last = last
    get_raw
  else
    #
    # put successful, we can build a new wfid
    #
    raw
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.