class Flexirest::ConnectionManager
Public Class Methods
Source
# File lib/flexirest/connection_manager.rb, line 14 def self.find_connection_for_url(url) Thread.current[:_connections] ||= {} found = Thread.current[:_connections].keys.detect {|key| url[0,key.length] == key} Thread.current[:_connections][found] if found end
Source
# File lib/flexirest/connection_manager.rb, line 7 def self.get_connection(base_url) raise Exception.new("Nil base URL passed to ConnectionManager.get_connection") if base_url.nil? Thread.current[:_connections] ||= {} Thread.current[:_connections][base_url] ||= Connection.new(base_url) Thread.current[:_connections][base_url] end
Source
# File lib/flexirest/connection_manager.rb, line 20 def self.in_parallel(base_url) begin require 'typhoeus' require 'typhoeus/adapters/faraday' unless Gem.loaded_specs["faraday-typhoeus"].present? rescue LoadError raise MissingOptionalLibraryError.new("To call '::Flexirest::ConnectionManager.in_parallel' you must include the gem 'Typhoeus' in your Gemfile.") end session = ConnectionManager.get_connection(base_url).session session.in_parallel do yield if block_given? end end
Source
# File lib/flexirest/connection_manager.rb, line 3 def self.reset! Thread.current[:_connections]={} end