def callback(*args, &block)
      @plugin_options ||= nil
      fail "callback must be called within a guard block" unless @plugin_options

      block, events = if args.size > 1
                        # block must be the first argument in that case, the
                        # yielded block is ignored
                        args
                      else
                        [block, args[0]]
                      end
      @plugin_options[:callbacks] << { events: events, listener: block }
    end
def callback(*args, &block)
      @plugin_options ||= nil
      fail "callback must be called within a guard block" unless @plugin_options

      block, events = if args.size > 1
                        # block must be the first argument in that case, the
                        # yielded block is ignored
                        args
                      else
                        [block, args[0]]
                      end
      @plugin_options[:callbacks] << { events: events, listener: block }
    end
Defines a callback to execute arbitrary code before or after any of
 the `start`, `stop`, `reload`, `run_all`, `run_on_changes`,
 `run_on_additions`, `run_on_modifications` and `run_on_removals` plugin
 method.

 @example Add callback before the `reload` action.
   callback(:reload_begin) { puts "Let's reload!" }

 @example Add callback before the `start` and `stop` actions.

   my_lambda = lambda do |plugin, event, *args|
     puts "Let's #{event} #{plugin} with #{args}!"
   end

   callback(my_lambda, [:start_begin, :start_end])

 @param [Array] args the callback arguments
 @yield a callback block