Method: Sfn::CommandModule::Callbacks#run_callbacks_for

Defined in:
lib/sfn/command_module/callbacks.rb

#run_callbacks_for(type, *args) ⇒ NilClass

Process requested callbacks

Parameters:

  • type (Symbol, String)

    name of callback type

Returns:

  • (NilClass)


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/sfn/command_module/callbacks.rb', line 33

def run_callbacks_for(type, *args)
  types = [type].flatten.compact
  type = types.first
  clbks = types.map do |c_type|
    callbacks_for(c_type)
  end.flatten(1).compact.uniq.each do |item|
    callback_name, callback, quiet = item
    quiet = true if config[:print_only]
    ui.info "Callback #{ui.color(type.to_s, :bold)} #{callback_name}: #{ui.color("starting", :yellow)}" unless quiet
    if args.empty?
      callback.call
    else
      callback.call(*args)
    end
    ui.info "Callback #{ui.color(type.to_s, :bold)} #{callback_name}: #{ui.color("complete", :green)}" unless quiet
  end
  nil
end