Sha256: a91b0ca48125bf6a0ef60ee9e4df1dcac995a8b3641717942b8aaba5f70613e5

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

module Flows
  class SharedContextPipeline
    module DSL
      # @api private
      module Tracks
        DEFAULT_ROUTER_DEF = RouterDefinition.new(
          Flows::Result::Ok => :next,
          Flows::Result::Err => :end
        )

        SingletonVarsSetup = Flows::Util::InheritableSingletonVars::DupStrategy.make_module(
          '@tracks' => TrackList.new
        )

        include SingletonVarsSetup

        attr_reader :tracks

        def step(name, router_def = DEFAULT_ROUTER_DEF, body: nil)
          tracks.add_step(
            Step.new(name: name, body: body, router_def: router_def)
          )
        end

        def mut_step(name, router_def = DEFAULT_ROUTER_DEF, body: nil)
          tracks.add_step(
            MutationStep.new(name: name, body: body, router_def: router_def)
          )
        end

        def wrap(name, router_def = DEFAULT_ROUTER_DEF, &tracks_definitions)
          tracks.add_step(
            Wrap.new(method_name: name, router_def: router_def, &tracks_definitions)
          )
        end

        def track(name, &block)
          track_before = tracks.current_track

          tracks.switch_track(name)
          instance_exec(&block)
          tracks.switch_track(track_before)
        end

        # :reek:UtilityFunction is allowed here
        def routes(routes_def)
          RouterDefinition.new(routes_def)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flows-0.6.0 lib/flows/shared_context_pipeline/dsl/tracks.rb