Class: RawgApi::Configuration
- Inherits:
-
Object
- Object
- RawgApi::Configuration
- Defined in:
- lib/rawg_api/configuration.rb
Constant Summary collapse
- DEFAULT_API_ENDPOINT =
'https://api.rawg.io/api'
- DEFAULT_APP_NAME =
'Rawg.io Ruby Client (rawg_api)'
- DEFAULT_PAGE_SIZE =
50
Instance Attribute Summary collapse
-
#app_name ⇒ Object
Returns the value of attribute app_name.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#page_size ⇒ Object
Returns the value of attribute page_size.
Instance Method Summary collapse
- #api_headers ⇒ Object
- #build_config ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
19 20 21 22 23 24 25 26 |
# 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 |
Instance Attribute Details
#app_name ⇒ Object
Returns the value of attribute app_name.
17 18 19 |
# File 'lib/rawg_api/configuration.rb', line 17 def app_name @app_name end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
17 18 19 |
# File 'lib/rawg_api/configuration.rb', line 17 def endpoint @endpoint end |
#headers ⇒ Object
Returns the value of attribute headers.
17 18 19 |
# File 'lib/rawg_api/configuration.rb', line 17 def headers @headers end |
#page_size ⇒ Object
Returns the value of attribute page_size.
17 18 19 |
# File 'lib/rawg_api/configuration.rb', line 17 def page_size @page_size end |
Instance Method Details
#api_headers ⇒ Object
39 40 41 |
# File 'lib/rawg_api/configuration.rb', line 39 def api_headers (headers || {}).merge({'User-Agent': @app_name}) end |
#build_config ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rawg_api/configuration.rb', line 28 def build_config { endpoints: { rawg_api: { root: @endpoint, headers: api_headers } } } end |