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



22
23
24
25
# File 'lib/train/plugins/transport.rb', line 22

def initialize(options = {})
  @options = merge_options({}, options || {})
  @logger = @options[:logger] || Logger.new(STDOUT)
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



40
41
42
# File 'lib/train/plugins/transport.rb', line 40

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



32
33
34
# File 'lib/train/plugins/transport.rb', line 32

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