Class: Dry::Initializer::Builder Private
- Inherits:
-
Object
- Object
- Dry::Initializer::Builder
- Includes:
- Plugins
- Defined in:
- lib/dry/initializer/builder.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Rebuilds the initializer every time a new argument defined
Instance Method Summary collapse
-
#call(mixin) ⇒ Object
private
Redeclares initializer and readers in the mixin module.
-
#define(name, settings) ⇒ Dry::Initializer::Builder
private
Defines new agrument and reloads mixin definitions.
-
#initialize ⇒ Builder
constructor
private
A new instance of Builder.
-
#register(plugin) ⇒ Dry::Initializer::Builder
private
Register new plugin to be applied as a chunk of code, or a proc to be evaluated in the instance’s scope.
Constructor Details
#initialize ⇒ Builder
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Builder.
10 11 12 13 14 |
# File 'lib/dry/initializer/builder.rb', line 10 def initialize @signature = Signature.new @plugins = Set.new [VariableSetter, TypeConstraint, DefaultProc] @parts = [] end |
Instance Method Details
#call(mixin) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Redeclares initializer and readers in the mixin module
49 50 51 52 53 54 |
# File 'lib/dry/initializer/builder.rb', line 49 def call(mixin) define_readers(mixin) reload_initializer(mixin) reload_callback(mixin) mixin end |
#define(name, settings) ⇒ Dry::Initializer::Builder
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Defines new agrument and reloads mixin definitions
35 36 37 38 39 40 41 42 43 |
# File 'lib/dry/initializer/builder.rb', line 35 def define(name, settings) signature = @signature.add(name, settings) parts = @parts + @plugins.map { |p| p.call(name, settings) }.compact copy do @signature = signature @parts = parts end end |
#register(plugin) ⇒ Dry::Initializer::Builder
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Register new plugin to be applied as a chunk of code, or a proc to be evaluated in the instance’s scope
23 24 25 26 |
# File 'lib/dry/initializer/builder.rb', line 23 def register(plugin) plugins = @plugins + [plugin] copy { @plugins = plugins } end |