Class: Backup::Notifier::Command

Inherits:
Base
  • Object
show all
Defined in:
lib/backup/notifier/command.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#max_retries, #message, #model, #on_failure, #on_success, #on_warning, #retry_waitsec

Instance Method Summary collapse

Methods inherited from Base

#perform!

Methods included from Config::Helpers

included

Methods included from Utilities::Helpers

#utility_remote

Constructor Details

#initialize(model, &block) ⇒ Command

Returns a new instance of Command.



36
37
38
39
40
41
# File 'lib/backup/notifier/command.rb', line 36

def initialize(model, &block)
  super
  instance_eval(&block) if block_given?

  @args ||= ["%L %v"]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Backup::Config::Helpers

Instance Attribute Details

#argsObject

Arguments to pass to the command.

Must be an array of strings or callable objects.

Callables will be invoked with #call(model, status), and the return value used as the argument.

In strings you can use the following placeholders:

%l - Model label %t - Model trigger %d - Backup duration (HH:MM:SS) %s - Status (success/failure/warning) %v - Status verb (succeeded/failed/succeeded with warnings)

All placeholders can be used with uppercase letters to capitalize the value.

Defaults to [ā€œ%L %vā€]



34
35
36
# File 'lib/backup/notifier/command.rb', line 34

def args
  @args
end

#commandObject

Command to execute.

Make sure it is accessible from your $PATH, or provide the absolute path to the command.



12
13
14
# File 'lib/backup/notifier/command.rb', line 12

def command
  @command
end