Skip to content

Utilities

Wiki Updater edited this page Jun 3, 2025 · 2 revisions

Flow offers a number of utilities which allow you to tap into and extend it's functionality.

Callbacks

Flow supports extensive callback functionality.

class ExampleFlow < ApplicationFlow
  before_trigger :callback_method
  after_trigger :callback_method

  around_trigger :callback_method

  before_operations :callback_method
  after_operations :callback_method

  around_operations :callback_method

  before_each_operation :callback_method
  after_each_operation :callback_method

  around_each_operation :callback_method

  before_operation OperationClassName, :callback_method
  after_operation OperationClassName, :callback_method

  around_operation OperationClassName, :callback_method
end

Memoization

Flow includes memoization functionality for operations.

class ExampleOperation < Operation
  before_execute :callback_method, memoized: true
end

Flow includes the very awesome ShortCircuIt gem for memoization.

Included Utilities

All Flows, Operations and States benefit from included utilities.

Technologic

All Flow objects receive logging methods.

class ExampleOperation < Operation
  def execute
    log_info { "This is logged at the info level" }
  end
end

Flow includes the Technologic gem for logging.

The gem adds methods to Flows, Operations, and States which share names with log levels.

log_trace
log_debug
log_info
log_warn
log_error
log_fatal

There are also accompanying query methods:

log_trace?
log_debug?
log_info?
log_warn?
log_error?
log_fatal?

Clone this wiki locally