Method: Amp::Command#before

Defined in:
lib/amp/commands/command.rb

#before(*args) {|options, arguments| ... } ⇒ Hash

This returns the list of actions to run before the command, in order (first ones are run first). You can modify this array in any way you choose, and it is run before the command is run.

Yields:

  • Extra code to run before the command is executed, after options are prepared.

Yield Parameters:

  • options

    The options that the dispatcher has prepared for the command. Includes global and local.

  • arguments

    All arguments passed to the command, after the options.

Returns:

  • (Hash)

    an array of strings and blocks. Strings are assumed to be command names and blocks are pieces of code to be run.



304
305
306
307
308
309
310
311
# File 'lib/amp/commands/command.rb', line 304

def before(*args, &block)
  args.each do |arg|
    @before << proc {|opts, args| Amp::Command[arg.to_sym].run(opts, args) }
  end
  
  @before << block if block
  @before
end