Class: LDA::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/lda_gov/configuration.rb

Constant Summary collapse

DEFAULT_BASE_URL =
'https://lda.gov/api/v1/'
DEFAULT_TIMEOUT =
30
DEFAULT_RETRIES =
3
DEFAULT_MAX_PAGES =
1000

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



12
13
14
15
16
17
18
19
20
# File 'lib/lda_gov/configuration.rb', line 12

def initialize
  @base_url  = DEFAULT_BASE_URL
  @timeout   = DEFAULT_TIMEOUT
  @retries   = DEFAULT_RETRIES
  @max_pages = DEFAULT_MAX_PAGES
  @logger    = nil
  @adapter   = Faraday.default_adapter
  @api_key   = ENV.fetch('LDA_API_KEY', nil)
end

Instance Attribute Details

#adapterObject

Returns the value of attribute adapter.



10
11
12
# File 'lib/lda_gov/configuration.rb', line 10

def adapter
  @adapter
end

#api_keyObject

Returns the value of attribute api_key.



10
11
12
# File 'lib/lda_gov/configuration.rb', line 10

def api_key
  @api_key
end

#base_urlObject

Returns the value of attribute base_url.



10
11
12
# File 'lib/lda_gov/configuration.rb', line 10

def base_url
  @base_url
end

#loggerObject

Returns the value of attribute logger.



10
11
12
# File 'lib/lda_gov/configuration.rb', line 10

def logger
  @logger
end

#max_pagesObject

Returns the value of attribute max_pages.



10
11
12
# File 'lib/lda_gov/configuration.rb', line 10

def max_pages
  @max_pages
end

#retriesObject

Returns the value of attribute retries.



10
11
12
# File 'lib/lda_gov/configuration.rb', line 10

def retries
  @retries
end

#timeoutObject

Returns the value of attribute timeout.



10
11
12
# File 'lib/lda_gov/configuration.rb', line 10

def timeout
  @timeout
end

Instance Method Details

#inspectObject



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

def inspect
  "#<#{self.class} base_url=#{base_url.inspect} timeout=#{timeout} retries=#{retries}>"
end

#to_hObject



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

def to_h
  {
    base_url: base_url,
    timeout: timeout,
    retries: retries,
    max_pages: max_pages,
    logger: logger,
    adapter: adapter,
    api_key: api_key
  }
end