Class: Train::Plugins::Transport

Inherits:
Object
  • Object
show all
Includes:
Extras
Defined in:
lib/train/plugins/transport.rb,
lib/train/plugins/base_connection.rb

Defined Under Namespace

Classes: BaseConnection

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Transport

Initialize a new Transport object

Parameters:

  • config (Hash)

    nil the configuration for this transport



21
22
23
24
25
26
27
28
29
30
# File 'lib/train/plugins/transport.rb', line 21

def initialize(options = {})
  @options = merge_options({}, options || {})
  @logger = @options[:logger] || Logger.new($stdout, level: :fatal)
  # Validates audit log configuration options if audit log is enabled
  # The reason to implement different validate method for audit log options is
  # to validate only audit log options and not to break any existing validate_option implementation.
  if !@options.empty? && @options[:enable_audit_log]
    validate_audit_log_options(options)
  end
end

Class Method Details

.name(name) ⇒ Object

Register the inheriting class with as a train plugin using the provided name.

Parameters:

  • name (String)

    of the plugin, by which it will be found



45
46
47
# File 'lib/train/plugins/transport.rb', line 45

def self.name(name)
  Train::Plugins.registry[name] = self
end

Instance Method Details

#connection(_options = nil) ⇒ Connection

Create a connection to the target. Options may be provided for additional configuration.

Parameters:

  • _options (Hash) (defaults to: nil)

    nil provide optional configuration params

Returns:

  • (Connection)

    the connection for this configuration

Raises:



37
38
39
# File 'lib/train/plugins/transport.rb', line 37

def connection(_options = nil)
  raise Train::ClientError, "#{self.class} does not implement #connection()"
end