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.
-
#intolerant_to_unknown_options ⇒ Dry::Initializer::Builder
private
Makes builder to provide options-intolerant initializer.
-
#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.
-
#tolerant_to_unknown_options ⇒ Dry::Initializer::Builder
private
Makes builder to provide options-tolerant initializer.
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
65 66 67 68 69 70 |
# File 'lib/dry/initializer/builder.rb', line 65 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
51 52 53 54 55 56 57 58 59 |
# File 'lib/dry/initializer/builder.rb', line 51 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 |
#intolerant_to_unknown_options ⇒ 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.
Makes builder to provide options-intolerant initializer
40 41 42 |
# File 'lib/dry/initializer/builder.rb', line 40 def copy { @tolerant = nil } 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 |
#tolerant_to_unknown_options ⇒ 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.
Makes builder to provide options-tolerant initializer
32 33 34 |
# File 'lib/dry/initializer/builder.rb', line 32 def copy { @tolerant = "**" } end |