Sha256: 29d23bc8bcab13f918a6be4a857469f221ddfa5cad7c37b35e1ec9dd869491cb

Contents?: true

Size: 767 Bytes

Versions: 2

Compression:

Stored size: 767 Bytes

Contents

require 'transflow/publisher'

module Transflow
  class StepDSL
    attr_reader :name

    attr_reader :handler

    attr_reader :container

    attr_reader :steps

    attr_reader :publish

    def initialize(name, options, container, steps, &block)
      @name = name
      @handler = options.fetch(:with, name)
      @publish = options.fetch(:publish, false)
      @container = container
      @steps = steps
      instance_exec(&block) if block
    end

    def step(*args, &block)
      self.class.new(*args, container, steps, &block).call
    end

    def call
      operation = container[handler]

      step =
        if publish
          Publisher.new(name, operation)
        else
          operation
        end

      steps[name] = step
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
transflow-0.2.0 lib/transflow/step_dsl.rb
transflow-0.1.0 lib/transflow/step_dsl.rb