lib/document.rb
# Creates a new version, ready to store documents in
# Work is performed in a flock block to avoid concurrent race condition
Creates a new version, ready to store documents in
Work is performed in a flock block to avoid concurrent race condition
Creates a new version ready to store documents in Work is performed in a flock block to avoid concurrent race condition
def new_version &block
      lockfile = directory + '.lock'
      nvn = nil
      lockfile.open 'w' do |f|
        f.flock File::LOCK_EX 
        nvn = next_version_number
        Dir.mkdir directory + nvn
        yield nvn if block_given?
      end
      nvn
    end
def new_version & block lockfile = directory + '.lock' nvn = nil lockfile . open 'w' do | f | f . flock File :: LOCK_EX nvn = next_version_number Dir . mkdir directory + nvn yield nvn if block_given? end nvn end
Creates a new version, ready to store documents in
Work is performed in a flock block to avoid concurrent race condition
Creates a new version ready to store documents in Work is performed in a flock block to avoid concurrent race condition
# lock is auto-released at end of block
block
<not_specific>