Module: EM::FTPD::FSD::Hooks

Defined in:
lib/em-ftpd-fsd/hooks.rb

Overview

Add callbacks methods to base class.

Examples:

Usage

class BasicDriver
  include EM::FTPD::FSD::Base

  before :put_file, :some_method
  after :delete_file, :some_other_method

  def some_method( path, tmp_path )
    ...
  end

  def some_other_method( path, value )
    ...
  end
end

Instance Method Summary collapse

Instance Method Details

#after(command, method) ⇒ Object

Set a method to be called after FTP command is executed That method will be invoked with same arguments that FTP command and an extra parameter containig the value yielded by the FTP command

Parameters:

  • command (Symbol)

    FTP command to be hooked

  • method (Symbol)

    Method to be called after FTP command



51
52
53
# File 'lib/em-ftpd-fsd/hooks.rb', line 51

def after( command, method )
  after_hooks[command] = method
end

#after_hooksArray

Defined hooks to be executed after FTP commands

Returns:

  • (Array)

    List of methods to be called after FTP commands



63
64
65
# File 'lib/em-ftpd-fsd/hooks.rb', line 63

def after_hooks
  @after_hooks ||= {}
end

#before(command, method) ⇒ Object

Set a method to be called before FTP command is executed That method will be invoked with same arguments that FTP command

Parameters:

  • command (Symbol)

    FTP command to be hooked

  • method (Symbol)

    Method to be called before FTP command



42
43
44
# File 'lib/em-ftpd-fsd/hooks.rb', line 42

def before( command, method )
  before_hooks[command] = method
end

#before_hooksArray

Defined hooks to be executed before FTP commands

Returns:

  • (Array)

    List of methods to be called before FTP commands



57
58
59
# File 'lib/em-ftpd-fsd/hooks.rb', line 57

def before_hooks
  @before_hooks ||= {}
end