Sha256: 4decdccbb75b8c9e3a2cbc8fcee7ab444a1307ea2177c586a0f2e52059bd4f04

Contents?: true

Size: 920 Bytes

Versions: 53

Compression:

Stored size: 920 Bytes

Contents

module Actions
  module Helpers
    module Lock
      # @see Lock.exclusive!
      def exclusive_lock!(resource)
        phase! Dynflow::Action::Plan
        parent_lock = ::ForemanTasks::Lock.for_resource(resource).where(:task_id => task.self_and_parents.map(&:id)).first
        if parent_lock
          ForemanTasks::Link.link_resource_and_related!(resource, task)
          parent_lock
        else
          ::ForemanTasks::Lock.exclusive!(resource, task)
        end
      end

      # @see Lock.lock!
      def lock!(resource, *_lock_names)
        Foreman::Deprecation.deprecation_warning('2.4', 'locking in foreman-tasks was reworked, please use a combination of exclusive_lock! and link! instead.')
        exclusive_lock!(resource)
      end

      # @see Lock.link!
      def link!(resource)
        phase! Dynflow::Action::Plan
        ::ForemanTasks::Link.link!(resource, task)
      end
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
foreman-tasks-10.0.2 app/lib/actions/helpers/lock.rb
foreman-tasks-10.0.1 app/lib/actions/helpers/lock.rb
foreman-tasks-10.0.0 app/lib/actions/helpers/lock.rb
foreman-tasks-9.2.3 app/lib/actions/helpers/lock.rb
foreman-tasks-9.2.2 app/lib/actions/helpers/lock.rb
foreman-tasks-9.2.1 app/lib/actions/helpers/lock.rb
foreman-tasks-9.2.0 app/lib/actions/helpers/lock.rb
foreman-tasks-9.1.1 app/lib/actions/helpers/lock.rb
foreman-tasks-9.0.4 app/lib/actions/helpers/lock.rb
foreman-tasks-9.1.0 app/lib/actions/helpers/lock.rb
foreman-tasks-9.0.2 app/lib/actions/helpers/lock.rb
foreman-tasks-9.0.1 app/lib/actions/helpers/lock.rb
foreman-tasks-8.3.3 app/lib/actions/helpers/lock.rb
foreman-tasks-9.0.0 app/lib/actions/helpers/lock.rb
foreman-tasks-8.2.1 app/lib/actions/helpers/lock.rb
foreman-tasks-8.1.4 app/lib/actions/helpers/lock.rb
foreman-tasks-8.3.2 app/lib/actions/helpers/lock.rb
foreman-tasks-8.3.1 app/lib/actions/helpers/lock.rb
foreman-tasks-8.1.3 app/lib/actions/helpers/lock.rb
foreman-tasks-8.3.0 app/lib/actions/helpers/lock.rb