Sha256: 835b1d1aaa8cb684467055d5f12f37c16e50d517976a6061a029c1196e6fea81

Contents?: true

Size: 306 Bytes

Versions: 5

Compression:

Stored size: 306 Bytes

Contents

#
# Defines whether an argument is optional
#
module Dry::Initializer::Dispatchers::PrepareOptional
  module_function

  def call(optional: nil, default: nil, required: nil, **options)
    optional ||= default
    optional &&= !required

    { optional: !!optional, default: default, **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_optional.rb
dry-initializer-3.0.3 lib/dry/initializer/dispatchers/prepare_optional.rb
dry-initializer-3.0.2 lib/dry/initializer/dispatchers/prepare_optional.rb
dry-initializer-3.0.1 lib/dry/initializer/dispatchers/prepare_optional.rb
dry-initializer-3.0.0 lib/dry/initializer/dispatchers/prepare_optional.rb