build_environment: typed: strict
Signed-off-by: botantony <antonsm21@gmail.com>
This commit is contained in:
parent
89d36e0dd5
commit
1cc4d0bc25
@ -1,11 +1,11 @@
|
|||||||
# typed: true # rubocop:todo Sorbet/StrictSigil
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Settings for the build environment.
|
# Settings for the build environment.
|
||||||
class BuildEnvironment
|
class BuildEnvironment
|
||||||
sig { params(settings: Symbol).void }
|
sig { params(settings: Symbol).void }
|
||||||
def initialize(*settings)
|
def initialize(*settings)
|
||||||
@settings = Set.new(settings)
|
@settings = T.let(Set.new(settings), T::Set[Symbol])
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(args: T::Enumerable[Symbol]).returns(T.self_type) }
|
sig { params(args: T::Enumerable[Symbol]).returns(T.self_type) }
|
||||||
@ -29,16 +29,17 @@ class BuildEnvironment
|
|||||||
module DSL
|
module DSL
|
||||||
# Initialise @env for each class which may use this DSL (e.g. each formula subclass).
|
# Initialise @env for each class which may use this DSL (e.g. each formula subclass).
|
||||||
# `env` may never be called and it needs to be initialised before the class is frozen.
|
# `env` may never be called and it needs to be initialised before the class is frozen.
|
||||||
|
sig { params(child: T.untyped).void }
|
||||||
def inherited(child)
|
def inherited(child)
|
||||||
super
|
super
|
||||||
child.instance_eval do
|
child.instance_eval do
|
||||||
@env = BuildEnvironment.new
|
@env = T.let(BuildEnvironment.new, T.nilable(BuildEnvironment))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { params(settings: Symbol).returns(BuildEnvironment) }
|
sig { params(settings: Symbol).returns(BuildEnvironment) }
|
||||||
def env(*settings)
|
def env(*settings)
|
||||||
@env.merge(settings)
|
T.must(@env).merge(settings)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user