Skip to content

Migration 2.1.rc1 to 2.1.rc11

Emanuele Magliozzi edited this page Aug 29, 2019 · 13 revisions

Since between 2.1.rc1 and 2.1.rc12 there's a significant (but necessary) internal refactoring, we decided to have a rather odd version jump.

The following Gemfile works. Note that you don't have to use all listed gems.

gem "trailblazer", ">= 2.1.0.rc12"

group :development, :test do
  gem "trailblazer-test"
  gem "trailblazer-developer"
end

Railway / Path

Before

module Create
  extend Trailblazer::Activity::Railway()
  module_function

  step :a, Output(:success) => :some_id 
  step :b, Output(:success) => :track
  step :c, magnetic_to: [:track]
end

Now

class Create < Trailblazer::Activity::Railway

  step :a, Output(:success) => Id(:some_id )
  step :b, Output(:success) => Track(:track)
  step :c, magnetic_to: :track
end

module_function

Before

module Create
  extend Trailblazer::Activity::Railway()
  module_function

  def a(ctx, *)
  end

  step method(:a)
end

Now

class Create < Trailblazer::Activity::Railway
  def self.a(ctx, *) # class method!
  end

  step method(:a)
end

FastTrack

In case the fast_track functionality has been used the new activity class must be inherited from Trailblazer::Activity::FastTrack and also Railway becomes Trailblazer::Operation::Railway.

Before

module Create
  extend Trailblazer::Activity::FastTrack()
  module_function

  def a(ctx, *)
    .....
    Railway.pass_fast!
  end

  step method(:a), fast_track: true
end

Now

class Create < Trailblazer::Activity::FastTrack()
  def a(ctx, *)
    .....
    Trailblazer::Operation::Railway.pass_fast!
  end

  step method(:a), fast_track: true
end

fast_track in any Macro (Nested/Wrap/Rescue)

For both Operation and Activity, a block in a Macro which return a fast_track signal needs to be wired to the external object

Before

class Create < Trailblazer::Operation
  step :start
  step Rescue(handler: :my_handler) {
    step :test
    step :fail_test, fast_track: true
  }
   
  ......
end

Now

class Create < Trailblazer::Operation
  step :start
  step Rescue(handler: :my_handler) {
    step :test
    step :fail_test, fast_track: true
  }, fast_track: true # need to add the fast_track option to the external step as well
   
  ......
end

NOTES

:input and :output in Nested(..)

Clone this wiki locally