Sha256: ad78f3b06a07c1b1edfa2bef5439bf0c05789c724c6ab646a3044848e51a8f63

Contents?: true

Size: 434 Bytes

Versions: 32

Compression:

Stored size: 434 Bytes

Contents

# frozen_string_literal: true

module Sequel::Plugins::WithLock
  module InstanceMethods
    # Execute block with lock
    #
    # @yield
    def with_lock(mode = "FOR NO KEY UPDATE", savepoint: true)
      return yield if @__locked
      @__locked = true

      begin
        db.transaction(savepoint: savepoint) do
          lock!(mode)
          yield
        end
      ensure
        @__locked = false
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
umbrellio-sequel-plugins-0.17.0 lib/sequel/plugins/with_lock.rb
umbrellio-sequel-plugins-0.16.1 lib/sequel/plugins/with_lock.rb
umbrellio-sequel-plugins-0.16.0.239 lib/sequel/plugins/with_lock.rb
umbrellio-sequel-plugins-0.16.0.238 lib/sequel/plugins/with_lock.rb
umbrellio-sequel-plugins-0.16.0.235 lib/sequel/plugins/with_lock.rb
umbrellio-sequel-plugins-0.16.0.234 lib/sequel/plugins/with_lock.rb
umbrellio-sequel-plugins-0.16.0.233 lib/sequel/plugins/with_lock.rb
umbrellio-sequel-plugins-0.16.0 lib/sequel/plugins/with_lock.rb
umbrellio-sequel-plugins-0.16.0.211 lib/sequel/plugins/with_lock.rb
umbrellio-sequel-plugins-0.15.0.198 lib/sequel/plugins/with_lock.rb
umbrellio-sequel-plugins-0.14.0.192 lib/sequel/plugins/with_lock.rb
umbrellio-sequel-plugins-0.14.0.189 lib/sequel/plugins/with_lock.rb
umbrellio-sequel-plugins-0.14.0.188 lib/sequel/plugins/with_lock.rb
umbrellio-sequel-plugins-0.14.0.187 lib/sequel/plugins/with_lock.rb
umbrellio-sequel-plugins-0.14.0 lib/sequel/plugins/with_lock.rb
umbrellio-sequel-plugins-0.13.0.185 lib/sequel/plugins/with_lock.rb
umbrellio-sequel-plugins-0.13.0.172 lib/sequel/plugins/with_lock.rb
umbrellio-sequel-plugins-0.13.0 lib/sequel/plugins/with_lock.rb
umbrellio-sequel-plugins-0.12.0.169 lib/sequel/plugins/with_lock.rb
umbrellio-sequel-plugins-0.12.0 lib/sequel/plugins/with_lock.rb