Module: HttpApiClient

Defined in:
lib/http_api_client.rb,
lib/http_api_client/client.rb,
lib/http_api_client/config.rb,
lib/http_api_client/errors.rb,
lib/http_api_client/version.rb,
lib/http_api_client/connection_factory.rb,
lib/http_api_client/rails_params_encoder.rb

Defined Under Namespace

Modules: Errors, RailsParamsEncoder Classes: Client, Config, ConnectionFactory, StubLogger, StubMetrics

Constant Summary collapse

VERSION =
"0.2.6"

Class Method Summary collapse

Class Method Details

.envObject



9
10
11
12
13
14
15
16
17
# File 'lib/http_api_client.rb', line 9

def self.env
  if @env
    @env
  elsif rails
    rails.env
  else
    "test"
  end
end

.env=(env) ⇒ Object



19
20
21
# File 'lib/http_api_client.rb', line 19

def self.env=(env)
  @env = env
end

.loggerObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/http_api_client.rb', line 23

def self.logger
  if @logger
    @logger
  elsif rails
    rails.logger
  else
    puts 'Logger not defined, using stub logger that does nothing. Set logger via HttpApiClient.logger = my_logger'
    StubLogger
  end
end

.logger=(logger) ⇒ Object



34
35
36
# File 'lib/http_api_client.rb', line 34

def self.logger=(logger)
  @logger = logger
end

.metricsObject



38
39
40
41
42
43
44
# File 'lib/http_api_client.rb', line 38

def self.metrics
  if @metrics
    @metrics
  else
    StubMetrics
  end
end

.metrics=(metrics) ⇒ Object



46
47
48
# File 'lib/http_api_client.rb', line 46

def self.metrics=(metrics)
  @metrics = metrics
end

.params_encoderObject



50
51
52
53
54
55
56
# File 'lib/http_api_client.rb', line 50

def self.params_encoder
  if rails
    RailsParamsEncoder
  else
    Faraday::Utils.default_params_encoder
  end
end