lib/messenger/messenger.rb in messenger-0.3.6 vs lib/messenger/messenger.rb in messenger-0.4.0

- old
+ new

@@ -1,6 +1,5 @@ -require 'system_timer' require 'base64' module Messenger def self.valid_url?(url) @@ -10,11 +9,17 @@ false end def self.deliver(url, message, options={}) service_handler = handler(url) - SystemTimer.timeout_after(options[:timeout] || 15) do - service_handler.deliver(url, message, options) + if defined?(SystemTimer) && SystemTimer.respond_to?(:timeout_after) + SystemTimer.timeout_after(options[:timeout] || 15) do + service_handler.deliver(url, message, options) + end + else + Timeout.timeout(options[:timeout] || 15) do + service_handler.deliver(url, message, options) + end end end def self.obfuscate(url) service_handler = handler(url)