Module: RobustClientSocket

Extended by:
Configuration
Defined in:
lib/version.rb,
lib/robust_client_socket.rb,
lib/robust_client_socket/http/client.rb,
lib/robust_client_socket/http/helpers.rb,
lib/robust_client_socket/configuration.rb,
lib/robust_client_socket/http/httparty_overrides.rb

Defined Under Namespace

Modules: Configuration, HTTP Classes: ConfigStore

Constant Summary collapse

VERSION =
'0.5.2'

Constants included from Configuration

Configuration::MIN_KEY_SIZE

Instance Attribute Summary

Attributes included from Configuration

#configuration, #configured

Class Method Summary collapse

Methods included from Configuration

configure, configured?, correct_configuration?

Class Method Details

.load!Object

rubocop:disable Metrics/AbcSize



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/robust_client_socket.rb', line 11

def load! # rubocop:disable Metrics/AbcSize
  raise 'You must configure RobustClientSocket first!' unless configured?

  require 'openssl'
  require 'httparty'
  require 'base64'
  require 'oj'

  require_relative 'robust_client_socket/http/httparty_overrides'
  require_relative 'robust_client_socket/http/helpers'
  require_relative 'robust_client_socket/http/client'

  configuration.services.each do |key, value|
    client = Class.new(RobustClientSocket::HTTP::Client)
    client.init(credentials: value, client_name: configuration.client_name, header_name: configuration.header_name)
    const_set(key.to_s.split('_').map(&:capitalize).join, client)
  end
end