Sha256: e1d61482c58cd054ca247c16dfcebe8064708be27f8b34f5e15541de880c758e

Contents?: true

Size: 688 Bytes

Versions: 3

Compression:

Stored size: 688 Bytes

Contents

module Pallets
  module DSL
    module Workflow
      def task(arg, depends_on: nil, max_failures: nil, &block)
        klass, dependencies = case arg
        when Hash
          # The `task Foo => Bar` notation
          arg.first
        else
          # The `task Foo, depends_on: Bar` notation
          [arg, depends_on]
        end

        task_class = klass.to_s
        dependencies = Array(dependencies).compact.uniq.map(&:to_s)
        graph.add(task_class, dependencies)

        task_config[task_class] = {
          'task_class' => task_class,
          'max_failures' => max_failures || Pallets.configuration.max_failures
        }

        nil
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pallets-0.5.1 lib/pallets/dsl/workflow.rb
pallets-0.5.0 lib/pallets/dsl/workflow.rb
pallets-0.4.0 lib/pallets/dsl/workflow.rb