Sha256: d8a7c27cefc288796e53764fbbd12e3a135b115c98086722cf357faadbb8127d

Contents?: true

Size: 495 Bytes

Versions: 3

Compression:

Stored size: 495 Bytes

Contents

module DepthFirst
  # Base parallel organizer class
  class ParallelOrganizer < Task
    TASKS = [].freeze

    def perform
      tasks.map { |task| execute_promise(task) }
           .reduce(options) { |a, e| resolve_promise(a, e) }
    end

    private

    def tasks
      self.class::TASKS
    end

    def execute_promise(task)
      Concurrent::Promise.new { task.new(options).perform }.execute
    end

    def resolve_promise(hsh, result)
      hsh.merge(result.value)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
depth_first-0.0.3 lib/depth_first/parallel_organizer.rb
depth_first-0.0.2 lib/depth_first/parallel_organizer.rb
depth_first-0.0.1 lib/depth_first/parallel_organizer.rb