Module: Dry::Initializer::DSL
- Included in:
- Dry::Initializer, Mixin
- Defined in:
- lib/dry/initializer/dsl.rb
Overview
Module-level DSL
Instance Attribute Summary collapse
-
#null ⇒ nil, Dry::Initializer::UNDEFINED
readonly
Setting for null (undefined value).
Instance Method Summary collapse
-
#[](undefined: true) ⇒ Dry::Initializer
Returns a version of the module with custom settings.
-
#define(procedure = nil) { ... } ⇒ Module
Returns mixin module to be included to target class by hand.
Instance Attribute Details
#null ⇒ nil, Dry::Initializer::UNDEFINED (readonly)
Setting for null (undefined value)
9 10 11 |
# File 'lib/dry/initializer/dsl.rb', line 9 def null @null end |
Instance Method Details
#[](undefined: true) ⇒ Dry::Initializer
Returns a version of the module with custom settings
15 16 17 18 19 20 21 22 |
# File 'lib/dry/initializer/dsl.rb', line 15 def [](undefined: true, **) null = undefined == false ? nil : UNDEFINED Module.new.tap do |mod| mod.extend DSL mod.include self mod.send(:instance_variable_set, :@null, null) end end |
#define(procedure = nil) { ... } ⇒ Module
Returns mixin module to be included to target class by hand
27 28 29 30 31 32 |
# File 'lib/dry/initializer/dsl.rb', line 27 def define(procedure = nil, &block) config = Config.new(null: null) config.instance_exec(&(procedure || block)) config.mixin.include Mixin::Root config.mixin end |