Sha256: 8c9d1c68f8f4e802e9b05d8da4aca8d67b30918b8d520b137b3e3aededc68b94

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

class Trailblazer::Operation
  module Wrap
    def self.import!(operation, import, wrap, _options={}, &block)
      pipe_api = API.new(operation, pipe = ::Pipetree::Flow.new)

      # DISCUSS: don't instance_exec when |pipe| given?
      # yield pipe_api # create the nested pipe.
      pipe_api.instance_exec(&block) # evaluate the nested pipe. this gets written onto `pipe`.

      import.(:&, ->(input, options) { wrap.(options, input, pipe, & ->{ pipe.(input, options) }) }, _options)
    end

    class API
      include Pipetree::DSL
      include Pipetree::DSL::Macros

      def initialize(target, pipe)
        @target, @pipe = target, pipe
      end

      def _insert(operator, proc, options={}) # TODO: test me.
        Pipetree::DSL.insert(@pipe, operator, proc, options, definer_name: @target.name)
      end

      def |(cfg, user_options={})
        Pipetree::DSL.import(@target, @pipe, cfg, user_options)
      end
      alias_method :step, :| # DISCUSS: uhm...
    end
  end # Wrap

  DSL.macro!(:Wrap, Wrap)
end

# (options, *) => (options, operation, bla)
# (*, params:, **) => (options, operation, bla, options)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trailblazer-2.0.0 lib/trailblazer/operation/wrap.rb
trailblazer-2.0.0.rc1 lib/trailblazer/operation/wrap.rb
trailblazer-2.0.0.beta3 lib/trailblazer/operation/wrap.rb
trailblazer-2.0.0.beta2 lib/trailblazer/operation/wrap.rb