Sha256: c70c4cc72c240fb47ade6e22672699f86fc7beb4f17d7c2f7ced9ad6499eb9ba

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

module Trailblazer::V2_1
  module Activity::Magnetic
    module DSL
      # works on a generic Dependencies structure that has no knowledge of magnetism.
      class Alterations
        def initialize
          @groups = Activity::Schema::Dependencies.new
          @future_magnetic_to = {} # DISCUSS: future - should it be here?
        end

        def add(id, options, **sequence_options)
          @groups.add(id, options, **sequence_options)

          # DISCUSS: future - should it be here?
          if magnetic_to = @future_magnetic_to.delete(id)
            magnetic_to( id, magnetic_to )
          end

          self
        end

        # make `id` magnetic_to
        def magnetic_to(id, magnetic_to)
          group, index = @groups.find(id) # this can be a future task!

          unless group # DISCUSS: future - should it be here?
            @future_magnetic_to[id] = magnetic_to
            return
          end

          arr = group[index].configuration.dup

          arr[0] = arr[0] + magnetic_to
          group.add(id, arr, replace: id)
        end

        # Returns array of tripletts.
        def to_a
          @groups.to_a
        end
      end
    end # DSL
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trailblazer-future-2.1.0.rc1 lib/trailblazer/v2_1/activity/dsl/magnetic/structure/alterations.rb