mirror of
https://github.com/gitlabhq/gitlabhq.git
synced 2025-08-01 16:46:16 +00:00
16 lines
306 B
Ruby
16 lines
306 B
Ruby
module Gitlab
|
|
class OptimisticLocking
|
|
def self.retry_lock(subject, &block)
|
|
loop do
|
|
begin
|
|
subject.transaction do
|
|
return block.call(subject)
|
|
end
|
|
rescue ActiveRecord::StaleObjectError
|
|
subject.reload
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|