Class: Updater::ORm::ActiveRecord
- Inherits:
-
Object
- Object
- Updater::ORm::ActiveRecord
- Defined in:
- lib/updater/orm/activerocord.rb
Instance Method Summary collapse
Instance Method Details
#lock(worker) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/updater/orm/activerocord.rb', line 6 def lock(worker) return true if locked? && locked_by == worker.name #all this to make sure the check and the lock are simultanious: ccnt = self.class.where(id: self.id, lock: nil).update_all(:lock=>worker.name) if 0 != cnt @lock_name = worker.name true else worker.say( "Worker #{worker.name} Failed to aquire lock on job #{id}" ) false end end |