Module: Dry::Initializer::Dispatchers::PrepareSource

Defined in:
lib/dry/initializer/dispatchers/prepare_source.rb

Overview

The dispatcher verifies a correctness of the source name of param or option, taken as a ‘:source` option.

We allow any stringified name for the source. For example, this syntax is correct because we accept any key in the original hash of arguments, but give them proper names:

“‘ruby class Foo

extend Dry::Initializer

option "", as: :first
option 1,  as: :second

end

foo = Foo.new(“”: 42, 1: 666) foo.first # => 42 foo.second # => 666 “‘

Class Method Summary collapse

Class Method Details

.call(source:, **options) ⇒ Object



25
26
27
# File 'lib/dry/initializer/dispatchers/prepare_source.rb', line 25

def call(source:, **options)
  { source: source.to_s.to_sym, **options }
end