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
Constant Summary
collapse
- VERSION =
"0.1.1"
Class Method Summary
collapse
Class Method Details
.env ⇒ Object
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
|
.logger ⇒ Object
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
Allow it to be injected on app startup. Eg. if using log4r etc
35
36
37
|
# File 'lib/http_api_client.rb', line 35
def self.logger=(logger)
@logger = logger
end
|
.params_encoder ⇒ Object
39
40
41
42
43
44
45
|
# File 'lib/http_api_client.rb', line 39
def self.params_encoder
if rails
RailsParamsEncoder
else
Faraday::Utils.default_params_encoder
end
end
|