Class: Kuby::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/kuby/definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app_name, &block) ⇒ Definition

T::Sig::WithoutRuntime.sig { params(app_name: String, block: T.nilable(T.proc.void)).void }



11
12
13
14
# File 'lib/kuby/definition.rb', line 11

def initialize(app_name, &block)
  @app_name = app_name
  # @environments = T.let(@environments, T.nilable(T::Hash[Symbol, Environment]))
end

Instance Attribute Details

#app_nameObject (readonly)

T::Sig::WithoutRuntime.sig { returns(String) }



8
9
10
# File 'lib/kuby/definition.rb', line 8

def app_name
  @app_name
end

Instance Method Details

#environment(name = Kuby.env, &block) ⇒ Object

T::Sig::WithoutRuntime.sig

params(
  name: Symbol,
  block: T.nilable(T.proc.void)
).returns(Kuby::Environment)



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/kuby/definition.rb', line 22

def environment(name = Kuby.env, &block)
  name = name.to_s

  environments[name] ||= Environment.new(name, self)

  if block_given?
    environments[name].instance_eval(&block)
  end

  environments[name]
end

#environmentsObject

T::Sig::WithoutRuntime.sig { returns(T::Hash[Symbol, Kuby::Environment]) }



35
36
37
# File 'lib/kuby/definition.rb', line 35

def environments
  @environments ||= {}
end