Sha256: cdd6aa8b940d3230fbaa2545a67b55bc491c3754f438f419eac9f791867b32dd
Contents?: true
Size: 1.59 KB
Versions: 6
Compression:
Stored size: 1.59 KB
Contents
require 'hoth/transport/base' require 'hoth/transport/http' require 'hoth/transport/https' require 'hoth/transport/bert' require 'hoth/transport/workling' require 'hoth/transport/beanstalkd' require 'hoth/encoding/json' require 'hoth/encoding/no_op' module Hoth module Transport POSSIBLE_TRANSPORTS = { :json_via_http => { :transport_class => Transport::Http, :encoder => Encoding::Json }, :http => :json_via_http, :json_via_https => { :transport_class => Transport::Https, :encoder => Encoding::Json }, :https => :json_via_https, :workling => { :transport_class => Transport::Workling }, :beanstalkd => { :transport_class => Transport::Beanstalkd, :encoder => Encoding::Json } } class <<self def create(transport_name, service) new_transport_with_encoding(transport_name, service) end 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 end end end
Version data entries
6 entries across 6 versions & 1 rubygems