Sha256: d4491463c43091015c179e8927aec62695586841496045cd3d7e1c9f8e6bb131

Contents?: true

Size: 984 Bytes

Versions: 6

Compression:

Stored size: 984 Bytes

Contents

module Actions
  module Helpers
    module Lock
      def self.included(base)
        base.extend(ClassMethods)
      end

      module ClassMethods

        def generate_phase(phase_module)
          super.tap do |phase_class|
            if phase_module == Dynflow::Action::PlanPhase
              phase_class.send(:include, PlanMethods)
            end
          end
        end

      end

      module PlanMethods

        def task
          ::ForemanTasks::Task::DynflowTask.find_by_external_id!(execution_plan_id)
        end

        # @see Lock.exclusive!
        def exclusive_lock!(resource)
          ::ForemanTasks::Lock.exclusive!(resource, task.id)
        end

        # @see Lock.lock!
        def lock!(resource, *lock_names)
          ::ForemanTasks::Lock.lock!(resource, task.id, *lock_names.flatten)
        end

        # @see Lock.link!
        def link!(resource)
          ::ForemanTasks::Lock.link!(resource, task.id)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
foreman-tasks-0.1.5 app/lib/actions/helpers/lock.rb
foreman-tasks-0.1.4 app/lib/actions/helpers/lock.rb
foreman-tasks-0.1.3 app/lib/actions/helpers/lock.rb
foreman-tasks-0.1.2 app/lib/actions/helpers/lock.rb
foreman-tasks-0.1.1 app/lib/actions/helpers/lock.rb
foreman-tasks-0.1.0 app/lib/actions/helpers/lock.rb