class Train::Transports::Docker
Public Instance Methods
connection(state = {}, &block)
click to toggle source
# File lib/train/transports/docker.rb, line 15 def connection(state = {}, &block) opts = merge_options(options, state || {}) validate_options(opts) if @connection && @connection_options == opts reuse_connection(&block) else create_new_connection(opts, &block) end end
Private Instance Methods
create_new_connection(options, &block)
click to toggle source
Creates a new Docker
connection instance and save it for potential future reuse.
@param options [Hash] connection options @return [Docker::Connection] a Docker
connection instance @api private
# File lib/train/transports/docker.rb, line 34 def create_new_connection(options, &block) if @connection logger.debug("[Docker] shutting previous connection #{@connection}") @connection.close end @connection_options = options @connection = Connection.new(options, &block) end
reuse_connection() { |connection| ... }
click to toggle source
Return the last saved Docker
connection instance.
@return [Docker::Connection] a Docker
connection instance @api private
# File lib/train/transports/docker.rb, line 48 def reuse_connection logger.debug("[Docker] reusing existing connection #{@connection}") yield @connection if block_given? @connection end