class Phantom::Phutex
Public Class Methods
new(lock_path)
click to toggle source
# File lib/phantom/phutex.rb, line 3 def initialize(lock_path) @path = lock_path end
Public Instance Methods
sync(&block)
click to toggle source
# File lib/phantom/phutex.rb, line 7 def sync(&block) raise ArgumentError.new('Block must be given.') if not block_given? File.open(@path, 'w') do |f| f.flock(File::LOCK_EX) block.call end end