Sha256: 009329e0bdbda4b93ea5dd0673f5280b91d642f2957b10ec570d9d398613713e

Contents?: true

Size: 1.33 KB

Versions: 13

Compression:

Stored size: 1.33 KB

Contents

module Trailblazer
  module Activity::Schema
    # Helps organizing the structure of the circuit and allows to define steps that
    # might be inserted in a completely different order, but it's experimental.
    #
    # Translates linear DSL calls that might refer to the same task several times into a linear "drawing instruction"
    # that can be consumed by Schema.bla.
    #
    # This class is experimental.
    class Dependencies
      def initialize
        @groups  = {
          start:      Sequence.new,
          main:       Sequence.new, # normal steps
          end:        Sequence.new, # ends
          unresolved: Sequence.new, # div
        }

        @order = [ :start, :main, :end, :unresolved ]
      end

      def add(id, seq_options, group: :main, **sequence_options)
        group = @groups[group] or raise "unknown group #{group}, implement me"

        group.add(id, seq_options, **sequence_options) # handles
      end

      def to_a
        @order.collect{ |name| @groups[name].to_a }.flatten(1)
      end

      # @api private
      def find(id)
        @groups.find do |name, group|
          index = group.send( :find_index, id )
          return group, index if index
        end
      end

      # @api private
      def self.sequence_keywords
        [ :group, :before, :after, :replace, :delete ]
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
trailblazer-activity-0.7.1 lib/trailblazer/activity/dsl/schema/dependencies.rb
trailblazer-activity-0.7.0 lib/trailblazer/activity/dsl/schema/dependencies.rb
trailblazer-activity-0.6.2 lib/trailblazer/activity/dsl/schema/dependencies.rb
trailblazer-activity-0.6.1 lib/trailblazer/activity/dsl/schema/dependencies.rb
trailblazer-activity-0.6.0 lib/trailblazer/activity/dsl/schema/dependencies.rb
trailblazer-activity-0.5.2 lib/trailblazer/activity/dsl/schema/dependencies.rb
trailblazer-activity-0.5.1 lib/trailblazer/activity/dsl/schema/dependencies.rb
trailblazer-activity-0.5.0 lib/trailblazer/activity/dsl/schema/dependencies.rb
trailblazer-activity-0.4.3 lib/trailblazer/activity/schema/dependencies.rb
trailblazer-activity-0.4.2 lib/trailblazer/activity/schema/dependencies.rb
trailblazer-activity-0.4.1 lib/trailblazer/activity/schema/dependencies.rb
trailblazer-activity-0.4.0 lib/trailblazer/activity/schema/dependencies.rb
trailblazer-activity-0.4.o lib/trailblazer/activity/schema/dependencies.rb