Module: Hoth::Transport

Defined in:
lib/hoth/transport.rb,
lib/hoth/transport/base.rb,
lib/hoth/transport/bert.rb,
lib/hoth/transport/http.rb,
lib/hoth/transport/https.rb,
lib/hoth/transport/workling.rb,
lib/hoth/transport/http_hmac.rb

Defined Under Namespace

Classes: Base, Bert, Http, HttpHmac, Https, HttpsHmac, Workling

Constant Summary collapse

POSSIBLE_TRANSPORTS =
{
  :json_via_http => {
    :transport_class => Transport::Http,
    :encoder => Encoding::Json
  },
  :http => :json_via_http,
  :json_via_http_hmac => {
    :transport_class => Transport::HttpHmac,
    :encoder => Encoding::Json
  },
  :json_via_https_hmac => {
    :transport_class => Transport::HttpsHmac,
    :encoder => Encoding::Json
  },
  :http_hmac => :json_via_http_hmac,
  :https_hmac => :json_via_https_hmac,

  :json_via_https => {
    :transport_class => Transport::Https,
    :encoder => Encoding::Json
  },
  :https => :json_via_https,
  :workling => {
    :transport_class => Transport::Workling
  }
}

Class Method Summary collapse

Class Method Details

.create(transport_name, service) ⇒ Object



42
43
44
# File 'lib/hoth/transport.rb', line 42

def create(transport_name, service)
  new_transport_with_encoding(transport_name, service)
end

.new_transport_with_encoding(transport_name, service) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/hoth/transport.rb', line 46

def new_transport_with_encoding(transport_name, service)
  if POSSIBLE_TRANSPORTS[transport_name.to_sym]
    if POSSIBLE_TRANSPORTS[transport_name.to_sym].kind_of?(Hash)
      POSSIBLE_TRANSPORTS[transport_name.to_sym][:transport_class].new(service, :encoder => POSSIBLE_TRANSPORTS[transport_name.to_sym][:encoder])
    else
      new_transport_with_encoding(POSSIBLE_TRANSPORTS[transport_name.to_sym], service)
    end
  else
    raise TransportException.new("specified transport '#{transport_name}' does not exist, use one of these: #{POSSIBLE_TRANSPORTS.keys.join(", ")}")
  end
end