module Elastics::HttpClients::Loader
Public Instance Methods
new_http_client()
click to toggle source
# File lib/elastics/http_clients/loader.rb, line 16 def new_http_client if Gem::Specification.respond_to?(:find_all_by_name) case # terrible way to check whether a gem is available. # Gem.available? was just perfect: that's probably the reason it has been deprecated! # https://github.com/rubygems/rubygems/issues/176 when Gem::Specification::find_all_by_name('patron').any? then require_patron when Gem::Specification::find_all_by_name('rest-client').any? then require_rest_client else Dummy.new end else case when Gem.available?('patron') then require_patron when Gem.available?('rest-client') then require_rest_client else Dummy.new end end end
Private Instance Methods
require_patron()
click to toggle source
# File lib/elastics/http_clients/loader.rb, line 37 def require_patron require 'patron' require 'elastics/http_clients/patron' Patron.new end
require_rest_client()
click to toggle source
# File lib/elastics/http_clients/loader.rb, line 43 def require_rest_client require 'rest-client' require 'elastics/http_clients/rest_client' RestClient.new end