Module: Dry::Initializer::Dispatchers

Extended by:
Dispatchers
Included in:
Dispatchers
Defined in:
lib/dry/initializer/dispatchers.rb,
lib/dry/initializer/dispatchers/wrap_type.rb,
lib/dry/initializer/dispatchers/check_type.rb,
lib/dry/initializer/dispatchers/unwrap_type.rb,
lib/dry/initializer/dispatchers/prepare_ivar.rb,
lib/dry/initializer/dispatchers/prepare_reader.rb,
lib/dry/initializer/dispatchers/prepare_source.rb,
lib/dry/initializer/dispatchers/prepare_target.rb,
lib/dry/initializer/dispatchers/prepare_default.rb,
lib/dry/initializer/dispatchers/prepare_optional.rb,
lib/dry/initializer/dispatchers/build_nested_type.rb

Defined Under Namespace

Modules: BuildNestedType, CheckType, PrepareDefault, PrepareIvar, PrepareOptional, PrepareReader, PrepareSource, PrepareTarget, UnwrapType, WrapType

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nullObject

Returns:

  • (Object)

71
72
73
# File 'lib/dry/initializer/dispatchers.rb', line 71

def null
  @null
end

#null Defines a value to be set to unassigned attributes(Definesavaluetobesettounassignedattributes) ⇒ Object

Returns:

  • (Object)

71
# File 'lib/dry/initializer/dispatchers.rb', line 71

attr_accessor :null

Instance Method Details

#<<(dispatcher) ⇒ self

Registers a new dispatcher

Parameters:

  • dispatcher (#call)

Returns:

  • (self)

    itself


79
80
81
82
# File 'lib/dry/initializer/dispatchers.rb', line 79

def <<(dispatcher)
  @pipeline = [dispatcher] + pipeline
  self
end

#call(**options) ⇒ Hash<Symbol, Objct>

Normalizes the source set of options

Parameters:

  • options (Hash<Symbol, Object>)

Returns:

  • (Hash<Symbol, Objct>)

    normalized set of options


90
91
92
93
# File 'lib/dry/initializer/dispatchers.rb', line 90

def call(**options)
  options = {null: null, **options}
  pipeline.reduce(options) { |opts, dispatcher| dispatcher.call(**opts) }
end