Sha256: da70b081410d08e89917d0f332f03e5fa1fdd0cf17f056a3a89ca4a3aa8f7613

Contents?: true

Size: 588 Bytes

Versions: 3

Compression:

Stored size: 588 Bytes

Contents

require 'with_advisory_lock'
require 'active_support/concern'

module ClosureTree
  module WithAdvisoryLock
    extend ActiveSupport::Concern

    def ct_with_advisory_lock(&block)
      self.class.ct_with_advisory_lock(&block)
    end

    included do
      class_eval do
        def self.ct_with_advisory_lock(&block)
          if _ct.options[:with_advisory_lock]
            with_advisory_lock("closure_tree") do
              transaction do
                yield
              end
            end
          else
            yield
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
closure_tree-4.1.0 lib/closure_tree/with_advisory_lock.rb
closure_tree-4.0.1 lib/closure_tree/with_advisory_lock.rb
closure_tree-4.0.0 lib/closure_tree/with_advisory_lock.rb