Class: Ghub::Configuration::Loader

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

Overview

Handles loading of configuration with environment defaults.

Instance Method Summary collapse

Constructor Details

#initialize(model = Content, environment: ENV) ⇒ Loader

Returns a new instance of Loader.



11
12
13
14
# File 'lib/ghub/configuration/loader.rb', line 11

def initialize model = Content, environment: ENV
  @model = model
  @environment = environment
end

Instance Method Details

#callObject



16
17
18
19
20
21
22
23
# File 'lib/ghub/configuration/loader.rb', line 16

def call
  model[
    accept: environment.fetch("GITHUB_API_ACCEPT", "application/vnd.github+json"),
    paginate: environment.fetch("GITHUB_API_PAGINATE", "false").to_bool,
    token: environment["GITHUB_API_TOKEN"],
    url: environment.fetch("GITHUB_API_URL", "https://api.github.com")
  ]
end