Method: Type.find

Defined in:
lib/type.rb

.find(query) ⇒ Type::Definition .find(query) ⇒ Type::Definition Also known as: []

Overloads:

  • .find(query) ⇒ Type::Definition

    Parameters:

  • .find(query) ⇒ Type::Definition

    Parameters:

    • query (String, Symbol)

      Find a named Type::Defintion. If the query ends with a ?, a nilable representation of the reolved type definition is returned.

Returns:



17
18
19
20
21
22
23
24
25
# File 'lib/type.rb', line 17

def find(query)
  return query if query.kind_of?(Definition)

  query = String(query)
  nilable = query.end_with?('?') && query.slice!(-1)

  definition = const_get(query)
  (nilable ? definition.nilable : definition)
end