class RawgApi::Configuration

Constants

DEFAULT_API_ENDPOINT
DEFAULT_APP_NAME
DEFAULT_PAGE_SIZE

Attributes

app_name[RW]
endpoint[RW]
headers[RW]
page_size[RW]

Public Class Methods

new() click to toggle source
# File lib/rawg_api/configuration.rb, line 19
def initialize
  @endpoint ||= DEFAULT_API_ENDPOINT
  @app_name ||= DEFAULT_APP_NAME
  @page_size ||= DEFAULT_PAGE_SIZE
  ::ApiStruct::Settings.configure do |config|
    config.endpoints = build_config[:endpoints]
  end
end

Public Instance Methods

api_headers() click to toggle source
# File lib/rawg_api/configuration.rb, line 39
def api_headers
  (headers || {}).merge({'User-Agent': @app_name})
end
build_config() click to toggle source
# File lib/rawg_api/configuration.rb, line 28
def build_config
  {
      endpoints: {
          rawg_api: {
              root: @endpoint,
              headers: api_headers
          }
      }
  }
end