Class: Kuby::Definition
- Inherits:
-
Object
- Object
- Kuby::Definition
- Extended by:
- T::Sig
- Defined in:
- lib/kuby/definition.rb
Instance Attribute Summary collapse
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
Instance Method Summary collapse
- #environment(name = Kuby.env, &block) ⇒ Object
- #environments ⇒ Object
-
#initialize(app_name, &block) ⇒ Definition
constructor
A new instance of Definition.
Constructor Details
#initialize(app_name, &block) ⇒ Definition
Returns a new instance of Definition.
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_name ⇒ Object (readonly)
Returns the value of attribute app_name.
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
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 T.must(environments[name]) end |
#environments ⇒ Object
35 36 37 |
# File 'lib/kuby/definition.rb', line 35 def environments @environments ||= {} end |