Sha256: 6f49116cb9c06a87593fe118adfe0fce3c9d34efcb392cb77ac1a232b35aa28b

Contents?: true

Size: 834 Bytes

Versions: 1

Compression:

Stored size: 834 Bytes

Contents

# DISCUSS: move to trailblazer-activity-test ?

# Helpers to quickly create steps and tasks.
module Trailblazer::V2_1::Activity::Testing
  # Creates a module with one step method for each name.
  #
  # @example
  #   extend T.def_steps(:create, :save)
  def self.def_steps(*names)
    Module.new do
      names.each do |name|
        define_method(name) do | ctx, ** |
          ctx[:seq] << name
          ctx.key?(name) ? ctx[name] : true
        end
      end
    end
  end

  # Creates a method instance with a task interface.
  #
  # @example
  #   task task: T.def_task(:create)
  def self.def_task(name)
    Module.new do
      define_singleton_method(name) do | (ctx, flow_options), ** |
        ctx[:seq] << name
        return Trailblazer::V2_1::Activity::Right, [ctx, flow_options]
      end
    end.method(name)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trailblazer-future-2.1.0.rc1 lib/trailblazer/v2_1/activity/testing.rb