Module: Etcd::Lockable

Included in:
Client
Defined in:
lib/etcd/mixins/lockable.rb

Instance Method Summary collapse

Instance Method Details

#lock(opts = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/etcd/mixins/lockable.rb', line 3

def lock(opts={})
  opts[:client] = opts[:client] || self
  lock = Lock.new(opts)
  lock.acquire
  begin
    yield lock.lock_id
  rescue Exception => e
    raise e
  ensure
    lock.release
  end
end