module Chaintown::Callbacks

Public Instance Methods

after_step_action(*callbacks) click to toggle source
# File lib/chaintown/callbacks.rb, line 18
def after_step_action(*callbacks)
  after_step_actions.concat(callbacks)
end
around_callback(callback, nested_callbacks, &block) click to toggle source
# File lib/chaintown/callbacks.rb, line 44
def around_callback(callback, nested_callbacks, &block)
  send(callback) do
    if nested_callbacks.present?
      around_callback(nested_callbacks.delete_at(0), nested_callbacks, &block)
    else
      block.call
    end
  end
end
around_step_action(*callbacks) click to toggle source
# File lib/chaintown/callbacks.rb, line 22
def around_step_action(*callbacks)
  around_step_actions.concat(callbacks)
end
before_step_action(*callbacks) click to toggle source
# File lib/chaintown/callbacks.rb, line 14
def before_step_action(*callbacks)
  before_step_actions.concat(callbacks)
end
run_after_actions() click to toggle source
# File lib/chaintown/callbacks.rb, line 31
def run_after_actions
  after_step_actions.each { |callback| send(callback) }
end
run_before_actions() click to toggle source
# File lib/chaintown/callbacks.rb, line 27
def run_before_actions
  before_step_actions.each { |callback| send(callback) }
end
with_around_actions() { || ... } click to toggle source
# File lib/chaintown/callbacks.rb, line 35
def with_around_actions
  if around_step_actions.present?
    callbacks = around_step_actions.dup
    around_callback(callbacks.delete_at(0), callbacks) { yield }
  else
    yield
  end
end