1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- class Sequencer::Unit
- extend ::Sequencer::Mixin::PrefixedConstantize
- PREFIX = 'Sequencer::Unit::'.freeze
-
-
-
-
-
-
-
- def self.process(unit, parameters, &)
- new(unit).process(parameters, &)
- end
-
-
-
-
-
-
- def initialize(unit)
- @unit = self.class.constantize(unit)
- end
-
-
-
-
-
-
-
-
- def process(parameters)
- @parameters = parameters
- instance = @unit.new(state)
-
- yield instance if block_given?
- state.process do
- instance.process
- end
- state.to_h
- end
- private
- def state
- @state ||= begin
- units = Sequencer::Units.new(
- @unit.name
- )
- sequence = Sequencer::Sequence.new(
- units: units,
- expecting: @unit.provides,
- )
- Sequencer::State.new(sequence,
- parameters: @parameters)
- end
- end
- end
|