class Protein::Transport

Public Class Methods

define(transport, opts = {}) click to toggle source
# File lib/protein/transport.rb, line 4
def define(transport, opts = {})
  if transport.is_a?(Class) || transport.is_a?(String)
    transport_class
  elsif transport.is_a?(Symbol)
    transport_base_class =
      case transport
      when :http
        Protein::HTTPAdapter
      when :amqp
        Protein::AMQPAdapter
      else
        raise(DefinitionError, "invalid transport: #{transport.inspect}")
      end

    transport_class = Class.new(transport_base_class)
    transport_class.from_hash(opts)
    transport_class
  else
    raise(DefinitionError, "invalid transport definition")
  end
end