Class: InferModel::CommonTypeGuesser

Inherits:
Object
  • Object
show all
Extended by:
Dry::Initializer, Callable
Defined in:
lib/infer_model/common_type_guesser.rb

Instance Method Summary collapse

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/infer_model/common_type_guesser.rb', line 15

def call
  inputs.each do |input|
    @available_types = ValueTypeGuesser.call(input, allow_blank:, available_types:, multi: true)
  end
  possible_detected_types = multi ? available_types : available_types.first

  @parsed_inputs = inputs.map { Parsers::BY_TYPE.fetch(available_types.first).call(_1) }

  CommonType.new(
    possible_detected_types,
    unique_constraint_possible:,
    non_null_constraint_possible:,
  )
end