Sha256: 3ab581e7b881eafecebada75a278242377a9d17ddd7c1362735e8178f87cbe1c

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

require 'transflow/step_dsl'
require 'transflow/transaction'

module Transflow
  # @api private
  class FlowDSL
    # @api private
    attr_reader :options

    # @api private
    attr_reader :container

    # @api private
    attr_reader :step_map

    # @api private
    attr_reader :step_options

    # @api private
    def initialize(options, &block)
      @options = options
      @container = options.fetch(:container)
      @step_map = {}
      @step_options = {}
      instance_exec(&block)
    end

    # @api public
    def steps(*names)
      names.reverse_each { |name| step(name) }
    end

    # @api public
    def step(name, options = {}, &block)
      StepDSL.new(name, step_options.merge(options), container, step_map, &block).call
    end

    # @api public
    def monadic(value)
      step_options.update(monadic: value)
    end

    # @api public
    def publish(value)
      step_options.update(publish: value)
    end

    # @api private
    def call
      Transaction.new(step_map)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
transflow-0.3.0 lib/transflow/flow_dsl.rb