module Dry::Initializer::Dispatchers::PrepareTarget
Constants
- RESERVED
List of variable names reserved by the gem
Public Instance Methods
call(source:, target: nil, as: nil, **options)
click to toggle source
# File lib/dry/initializer/dispatchers/prepare_target.rb, line 23 def call(source:, target: nil, as: nil, **options) target ||= as || source target = target.to_s.to_sym.downcase check_ruby_name!(target) check_reserved_names!(target) {source: source, target: target, **options} end
Private Instance Methods
check_reserved_names!(target)
click to toggle source
# File lib/dry/initializer/dispatchers/prepare_target.rb, line 42 def check_reserved_names!(target) return unless RESERVED.include?(target) raise ArgumentError, "The method name `#{target}` is reserved by the dry-initializer gem" end
check_ruby_name!(target)
click to toggle source
# File lib/dry/initializer/dispatchers/prepare_target.rb, line 35 def check_ruby_name!(target) return if target[/\A[[:alpha:]_][[:alnum:]_]*\??\z/u] raise ArgumentError, "The name `#{target}` is not allowed for Ruby methods" end