lib/transflow/flow_dsl.rb in transflow-0.0.2 vs lib/transflow/flow_dsl.rb in transflow-0.1.0

- old
+ new

@@ -1,45 +1,39 @@ -require 'transproc' - require 'transflow/step_dsl' require 'transflow/transaction' module Transflow + # @api private class FlowDSL - module Registry - extend Transproc::Registry - end - - def self.[](op) - if op.respond_to?(:>>) - op - else - Registry[op] - end - end - + # @api private attr_reader :options + # @api private attr_reader :container - attr_reader :steps + # @api private + attr_reader :step_map + # @api private def initialize(options, &block) @options = options @container = options.fetch(:container) - @steps = {} + @step_map = {} instance_exec(&block) end - def step(*args, &block) - StepDSL.new(*args, container, steps, &block).call + # @api private + def steps(*names) + names.reverse_each { |name| step(name) } end - def call - Transaction.new(steps, operations.reduce(:>>)) + # @api private + def step(name, options = {}, &block) + StepDSL.new(name, options, container, step_map, &block).call end - def operations - steps.values.reverse.map { |op| self.class[op] } + # @api private + def call + Transaction.new(step_map) end end end