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

.assume_nilable?(type_value) ⇒ Boolean

: (untyped type_value) -> bool

Returns:

  • (Boolean)


27
28
29
# File 'lib/tapioca/dsl/helpers/active_model_type_helper.rb', line 27

def assume_nilable?(type_value)
  !type_value.respond_to?(:__tapioca_type)
end

.type_for(type_value) ⇒ Object

Returns the type indicated by the custom ActiveModel::Type::Value. Accepts subclasses of ActiveModel::Type::Value as well as classes that implement similar methods. : (untyped type_value) -> String



14
15
16
17
18
19
20
21
22
23
24
# 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_tapioca_type(type_value) ||
    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