Module: ProcessLock::ExecuteOnce
- Included in:
- WithProcessLock
- Defined in:
- lib/process_lock/execute_once.rb
Instance Method Summary collapse
-
#execute_once(key, &blk) ⇒ Object
Tries to run the given block and raises an exception if the process is locked.
Instance Method Details
#execute_once(key, &blk) ⇒ Object
Tries to run the given block and raises an exception if the process is locked
6 7 8 9 10 11 12 13 |
# File 'lib/process_lock/execute_once.rb', line 6 def execute_once(key, &blk) if can_execute?(key) execute(key, &blk) else redis.quit raise ProcessLockError, key: key end end |