Module: Chaintown::Callbacks

Extended by:
ActiveSupport::Concern
Defined in:
lib/chaintown/callbacks.rb

Instance Method Summary collapse

Instance Method Details

#around_callback(callback, nested_callbacks, &block) ⇒ Object



44
45
46
47
48
49
50
51
52
# 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

#run_after_actionsObject



31
32
33
# File 'lib/chaintown/callbacks.rb', line 31

def run_after_actions
  after_step_actions.each { |callback| send(callback) }
end

#run_before_actionsObject



27
28
29
# File 'lib/chaintown/callbacks.rb', line 27

def run_before_actions
  before_step_actions.each { |callback| send(callback) }
end

#with_around_actionsObject



35
36
37
38
39
40
41
42
# 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