Sha256: 75e1dc301684ba531e6bee409bf90c1a137dd292cced8a8cc9b090ab8682effb

Contents?: true

Size: 647 Bytes

Versions: 5

Compression:

Stored size: 647 Bytes

Contents

#
# 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
# ```
#
module Dry::Initializer::Dispatchers::PrepareSource
  module_function

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dry-initializer-3.0.4 lib/dry/initializer/dispatchers/prepare_source.rb
dry-initializer-3.0.3 lib/dry/initializer/dispatchers/prepare_source.rb
dry-initializer-3.0.2 lib/dry/initializer/dispatchers/prepare_source.rb
dry-initializer-3.0.1 lib/dry/initializer/dispatchers/prepare_source.rb
dry-initializer-3.0.0 lib/dry/initializer/dispatchers/prepare_source.rb