1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
# encoding: utf-8
#
# Author:: Dominik Richter (<dominik.richter@gmail.com>)
# Author:: Christoph Hartmann (<chris@lollyrock.com>)
require_relative "errors"
module Train
class Plugins
require_relative "plugins/transport"
class << self
# Retrieve the current plugin registry, containing all plugin names
# and their transport handlers.
#
# @return [Hash] map with plugin names and plugins
def registry
@registry ||= {}
end
end
end
# Create a new plugin by inheriting from the class returned by this method.
# Create a versioned plugin by providing the transport layer plugin version
# to this method. It will then select the correct class to inherit from.
#
# The plugin version determins what methods will be available to your plugin.
#
# @param [Int] version = 1 the plugin version to use
# @return [Transport] the versioned transport base class
def self.plugin(version = 1)
if version != 1
raise ClientError,
"Only understand train plugin version 1. You are trying to "\
"initialize a train plugin #{version}, which is not supported "\
"in the current release of train."
end
::Train::Plugins::Transport
end
end
|