lib/yodeler/adapters/http_adapter.rb in yodeler-0.1.1 vs lib/yodeler/adapters/http_adapter.rb in yodeler-0.1.2

- old
+ new

@@ -6,11 +6,11 @@ attr_accessor :port attr_accessor :path attr_accessor :use_ssl attr_accessor :default_params - def initialize(host=nil, port:nil, path:nil, use_ssl:false, params:{}) + def initialize(host = nil, port:nil, path:nil, use_ssl:false, params:{}) @host = host @port = port @path = path @use_ssl = use_ssl @default_params = params @@ -24,17 +24,19 @@ def handle(type, &block) @handlers[type] = block end def dispatch(metric) - (@handlers[metric.type] || @handlers[:default]).call(url, metric, default_params) + dispatcher = @handlers[metric.type] || @handlers[:default] + dispatcher.call(url, metric, default_params) end def url "#{protocol}://#{host_with_port}#{path}" end private + def host_with_port if port "#{host}:#{port}" else host