If the name option was omitted and the type has a namespace, the type checker will have the same namespace. e.g: Kind::Types.add(Account::User) will generate Kind.of.Account::User(value)/Kind.is.Account::User(value).
In the v4 Kind.of(<Type>, value) will only be used to check and raise an exception if the given value hasn't the expected type. So, Kind::Of(Type) will be the new way to build type checkers.
data={first_name: 'Rodrigo',last_name: 'Rodrigues'}modulePersonIntroduction1extendselfdefcall(data)"Hi my name is #{full_name(data)}, I'm #{age(data)}"endprivatedeffull_name(data)casedatawhenHashthen"#{data[:first_name]}#{data[:last_name]}"else'John Doe'endenddefage(data)casedatawhenHashthendata.fetch(:age,0)else0endendendmodulePersonIntroduction2extendselfdefcall(data)"Hi my name is #{full_name(data)}, I'm #{age(data)}"endprivatedeffull_name(data)return'John Doe'unlessdata.is_a?(Hash)"#{data[:first_name]}#{data[:last_name]}"enddefage(data)data.is_a?(Hash) ? data.fetch(:age,0) : 0endendmodulePersonIntroduction3extendselfdefcall(arg)data=Kind::Optional[Kind.of.Hash.or_nil(arg)]"Hi my name is #{full_name(data)}, I'm #{age(data)}"endprivatedeffull_name(optional)optional.map{ |data| "#{data[:first_name]}#{data[:last_name]}"}.value_or{'John Doe'}enddefage(optional)optional.map{ |data| data[:age]}.value_or(0)endend
Expectation:
modulePersonIntroduction3extendselfdefcall(arg)data=Kind::Of::Hash.as_optional(arg)"Hi my name is #{full_name(data)}, I'm #{age(data)}"endprivatedeffull_name(optional)optional.map{ |data| "#{data[:first_name]}#{data[:last_name]}"}.value_or{'John Doe'}enddefage(optional)optional.map{ |data| data[:age]}.value_or(0)endend