Skip to content

Latest commit

 

History

History
36 lines (31 loc) · 951 Bytes

generator_config.md

File metadata and controls

36 lines (31 loc) · 951 Bytes

Config

Tapioca::Compilers::Dsl::Config generates RBI files for classes generated by the config gem.

The gem creates a Config::Options instance based on the settings files and/or env variables. It then assigns this instance to a constant with a configurable name, by default Settings. Application code uses methods on this constant to read off config values.

For a setting file like the following:

---
github:
  token: 12345
  client_id: 54321
  client_secret: super_secret

and a Config setup like:

Config.setup do |config|
  config.const_name = "AppSettings"
end

this generator will produce the following RBI file:

AppSettings = T.let(T.unsafe(nil), AppSettingsConfigOptions)

class AppSettingsConfigOptions < ::Config::Options
  sig { returns(T.untyped) }
  def github; end

  sig { params(value: T.untyped).returns(T.untyped) }
  def github=(value); end
end