Sha256: 89da5cda653d04a861775d4f0d663981a54221e163092be2939d3d5bb293d175

Contents?: true

Size: 1 KB

Versions: 5

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

require 'dry-equalizer'

module Attr
  module Gather
    module Workflow
      # @api private
      class Task
        send :include, Dry::Equalizer(:name, :depends_on)

        attr_accessor :name, :depends_on

        # Initialize a new DeepMerge aggregator
        #
        # @param name [String] name of the task
        # @param depends_on [Array<Task>] tasks needed before running this task
        #
        # @api private
        def initialize(name:, depends_on: [])
          @name = name
          @depends_on = depends_on
        end

        # Check if this task depends on a given task
        #
        # @param other_task [Task] task to check
        def depends_on?(other_task)
          depends_on.include?(other_task)
        end

        def fullfilled_given_remaining_tasks?(task_list)
          task_list.none? { |list_task| depends_on?(list_task) }
        end

        def as_json
          { name: name, depends_on: depends_on }
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
attr-gather-1.5.1 lib/attr/gather/workflow/task.rb
attr-gather-1.4.0 lib/attr/gather/workflow/task.rb
attr-gather-1.2.1 lib/attr/gather/workflow/task.rb
attr-gather-1.3.0 lib/attr/gather/workflow/task.rb
attr-gather-1.2.0 lib/attr/gather/workflow/task.rb