Class: ET::FallbackConnection

Inherits:
Object
  • Object
show all
Defined in:
lib/et/fallback_connection.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}, &block) ⇒ FallbackConnection

Returns a new instance of FallbackConnection.



6
7
8
9
10
# File 'lib/et/fallback_connection.rb', line 6

def initialize(opts = {}, &block)
  @connection = Faraday.new(opts, &block)

  @fallback_connection = Faraday.new(opts.merge(:ssl => {:verify => false}), &block)
end

Instance Method Details

#open(&block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/et/fallback_connection.rb', line 12

def open(&block)
  begin
    block.call(@connection)
  rescue Faraday::SSLError => e
    if operating_system.platform_family?(:windows)
      block.call(@fallback_connection)
    else
      raise e
    end
  end
end