Class: Tapioca::Compilers::EnvConfig

Inherits:
Dsl::Compiler
  • Object
show all
Defined in:
sorbet/tapioca/compilers/env_config.rb

Constant Summary collapse

ConstantType =
type_member { { fixed: Module } }

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.gather_constantsEnumerable<Module>

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



13
# File 'sorbet/tapioca/compilers/env_config.rb', line 13

def self.gather_constants = [Homebrew::EnvConfig]

Instance Method Details

#decoratevoid

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'sorbet/tapioca/compilers/env_config.rb', line 16

def decorate
  root.create_module(T.must(constant.name)) do |mod|
    dynamic_methods = {}
    Homebrew::EnvConfig::ENVS.each do |env, hash|
      next if Homebrew::EnvConfig::CUSTOM_IMPLEMENTATIONS.include?(env)

      name = Homebrew::EnvConfig.env_method_name(env, hash)
      dynamic_methods[name] = hash[:default]
    end

    dynamic_methods.each do |method, default|
      return_type = if method.end_with?("?")
        T::Boolean
      elsif default
        default.class
      else
        T.nilable(String)
      end

      mod.create_method(method, return_type:, class_method: true)
    end
  end
end