Module: Dry::Initializer::Dispatchers::PrepareTarget
- Extended by:
- PrepareTarget
- Included in:
- PrepareTarget
- Defined in:
- lib/dry/initializer/dispatchers/prepare_target.rb
Overview
Prepares the target name of a parameter or an option.
Unlike source, the target must satisfy requirements for Ruby variable names. It also shouldn’t be in conflict with names used by the gem.
Constant Summary collapse
- RESERVED =
List of variable names reserved by the gem
%i[ __dry_initializer_options__ __dry_initializer_config__ __dry_initializer_value__ __dry_initializer_definition__ __dry_initializer_initializer__ ].freeze
Instance Method Summary collapse
Instance Method Details
#call(source:, target: nil, as: nil, **options) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/dry/initializer/dispatchers/prepare_target.rb', line 19 def call(source:, target: nil, as: nil, **) target ||= as || source target = target.to_s.to_sym.downcase check_ruby_name!(target) check_reserved_names!(target) { source: source, target: target, ** } end |