Module: Tapioca::Dsl::Helpers::ActiveModelTypeHelper

Extended by:
T::Sig
Defined in:
lib/tapioca/dsl/helpers/active_model_type_helper.rb

Class Method Summary collapse

Class Method Details

.type_for(type_value) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/tapioca/dsl/helpers/active_model_type_helper.rb', line 14

def type_for(type_value)
  return "T.untyped" if Runtime::GenericTypeRegistry.generic_type_instance?(type_value)

  type = lookup_return_type_of_method(type_value, :deserialize) ||
    lookup_return_type_of_method(type_value, :cast) ||
    lookup_return_type_of_method(type_value, :cast_value) ||
    lookup_arg_type_of_method(type_value, :serialize) ||
    T.untyped
  type.to_s
end