Module: CircuitBreaker::WorkflowBuilder::DSL::PrettyPrint

Included in:
Workflow
Defined in:
lib/circuit_breaker/workflow_dsl.rb

Instance Method Summary collapse

Instance Method Details

#pretty_printObject



278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/circuit_breaker/workflow_dsl.rb', line 278

def pretty_print
  puts "States:"
  puts "  #{@states.join(' -> ')}"
  puts "\nTransitions:"
  @transitions.each do |transition|
    puts "  #{transition.name}: #{transition.from_state} -> #{transition.to_state}"
    if transition.rules && !transition.rules.empty?
      puts "    Rules:"
      if transition.rules[:all]
        puts "      All of:"
        transition.rules[:all].each { |rule| puts "        - #{rule}" }
      end
      if transition.rules[:any]
        puts "      Any of:"
        transition.rules[:any].each { |rule| puts "        - #{rule}" }
      end
    end
    if transition.action_context && !transition.action_context.results.empty?
      puts "    Actions:"
      transition.action_context.results.each do |name, result|
        puts "      #{name}: #{result}"
      end
    end
  end
end