Class: Dry::Initializer::Arguments Private
- Inherits:
-
Object
- Object
- Dry::Initializer::Arguments
- Includes:
- Errors, Enumerable
- Defined in:
- lib/dry/initializer/arguments.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.
Collection of definitions for arguments
Instance Method Summary collapse
- #[](name) ⇒ Object private
- #add(name, options) ⇒ Object private
- #declaration ⇒ Object private
-
#initialize(**arguments) ⇒ Arguments
constructor
private
A new instance of Arguments.
Constructor Details
#initialize(**arguments) ⇒ Arguments
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 Arguments.
10 11 12 |
# File 'lib/dry/initializer/arguments.rb', line 10 def initialize(**arguments) @arguments = arguments end |
Instance Method Details
#[](name) ⇒ 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.
34 35 36 |
# File 'lib/dry/initializer/arguments.rb', line 34 def [](name) @arguments[name] end |
#add(name, options) ⇒ 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.
14 15 16 17 18 19 20 |
# File 'lib/dry/initializer/arguments.rb', line 14 def add(name, ) validate_uniqueness(name) validate_presence_of_default(name, ) new_argument = Argument.new(name, ) self.class.new @arguments.merge(name.to_sym => new_argument) end |
#declaration ⇒ 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.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/dry/initializer/arguments.rb', line 22 def declaration <<-RUBY attr_reader #{select(&:reader).map { |arg| ":#{arg.name}" }.join(", ")} define_method :initialize do |#{signature}| #{assign_arguments} #{take_declarations} #{assign_defaults} #{check_constraints} end RUBY end |