Module: ActiveRestClient::Configuration::ClassMethods

Defined in:
lib/active_rest_client/configuration.rb

Constant Summary collapse

@@base_url =
nil

Instance Method Summary collapse

Instance Method Details

#_reset_configuration!Object



72
73
74
75
76
77
78
79
# File 'lib/active_rest_client/configuration.rb', line 72

def _reset_configuration!
  @base_url         = nil
  @@base_url        = nil
  @whiny_missing    = nil
  @lazy_load        = false
  @faraday_config   = default_faraday_config
  @adapter          = :patron
end

#adapterObject



31
32
33
# File 'lib/active_rest_client/configuration.rb', line 31

def adapter
  @adapter ||= :patron
end

#adapter=(adapter) ⇒ Object



26
27
28
29
# File 'lib/active_rest_client/configuration.rb', line 26

def adapter=(adapter)
  ActiveRestClient::Logger.info "\033[1;4;32m#{name}\033[0m Adapter set to be #{adapter}"
  @adapter = adapter
end

#base_url(value = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/active_rest_client/configuration.rb', line 7

def base_url(value = nil)
  if value.nil?
    if @base_url.nil?
      @@base_url
    else
      @base_url
    end
  else
    value = value.gsub(/\/$/, '')
    @base_url = value
  end
end

#base_url=(value) ⇒ Object



20
21
22
23
24
# File 'lib/active_rest_client/configuration.rb', line 20

def base_url=(value)
  ActiveRestClient::Logger.info "\033[1;4;32m#{name}\033[0m Base URL set to be #{value}"
  value = value.gsub(/\/+$/, '')
  @@base_url = value
end

#faraday_config(&block) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/active_rest_client/configuration.rb', line 35

def faraday_config(&block)
  if block
    @faraday_config = block
  else
    @faraday_config ||= default_faraday_config
  end
end

#lazy_load!Object



43
44
45
# File 'lib/active_rest_client/configuration.rb', line 43

def lazy_load!
  @lazy_load = true
end

#lazy_load?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/active_rest_client/configuration.rb', line 47

def lazy_load?
  @lazy_load || false
end

#proxy(value = nil) ⇒ Object



68
69
70
# File 'lib/active_rest_client/configuration.rb', line 68

def proxy(value = nil)
  value ? @proxy = value : @proxy || nil
end

#translator(value = nil) ⇒ Object



63
64
65
66
# File 'lib/active_rest_client/configuration.rb', line 63

def translator(value = nil)
  ActiveRestClient::Logger.warn("DEPRECATION: The translator functionality of ActiveRestClient has been replaced with proxy functionality, see https://github.com/whichdigital/active-rest-client#proxying-apis for more information") unless value.nil?
  value ? @translator = value : @translator || nil
end

#verbose(value = nil) ⇒ Object



59
60
61
# File 'lib/active_rest_client/configuration.rb', line 59

def verbose(value = nil)
  value ? @verbose = value : @verbose || false
end

#verbose!Object



55
56
57
# File 'lib/active_rest_client/configuration.rb', line 55

def verbose!
  @verbose = true
end

#whiny_missing(value = nil) ⇒ Object



51
52
53
# File 'lib/active_rest_client/configuration.rb', line 51

def whiny_missing(value = nil)
  value ? @whiny_missing = value : @whiny_missing || false
end