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(mixin, name, settings) ⇒ self
private
Defines new agrument and reloads mixin definitions.
-
#initialize ⇒ Builder
constructor
private
A new instance of Builder.
-
#register(plugin) ⇒ Object
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.
9 10 11 12 13 |
# File 'lib/dry/initializer/builder.rb', line 9 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
48 49 50 51 52 |
# File 'lib/dry/initializer/builder.rb', line 48 def call(mixin) define_readers(mixin) reload_initializer(mixin) reload_callback(mixin) end |
#define(mixin, name, settings) ⇒ self
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
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/dry/initializer/builder.rb', line 33 def define(mixin, name, settings) signature = @signature.add(name, settings) parts = @parts + @plugins.map { |p| p.call(name, settings) }.compact copy do @signature = signature @parts = parts call(mixin) end end |
#register(plugin) ⇒ 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.
Register new plugin to be applied as a chunk of code, or a proc to be evaluated in the instance’s scope
20 21 22 23 |
# File 'lib/dry/initializer/builder.rb', line 20 def register(plugin) plugins = @plugins + [plugin] copy { @plugins = plugins } end |