Module: Parlour::Mixin::Searchable

Extended by:
T::Generic, T::Sig
Included in:
RbiGenerator::Namespace, RbsGenerator::Namespace
Defined in:
lib/parlour/mixin/searchable.rb

Overview

Extends a particular type system’s Namespace class to provide searchable children.

Constant Summary collapse

Child =
type_member {{ upper: TypedObject }}

Instance Method Summary collapse

Instance Method Details

#childrenObject



16
# File 'lib/parlour/mixin/searchable.rb', line 16

def children; end

#find(name: nil, type: nil) ⇒ Object

Finds the first child matching the given predicates.

Parameters:

  • name (String, nil) (defaults to: nil)

    The name of the child to filter on, or nil.

  • type (Class, nil) (defaults to: nil)

    The type of the child to filter on, or nil. The type is compared using #is_a?.



24
25
26
# File 'lib/parlour/mixin/searchable.rb', line 24

def find(name: nil, type: nil)
  T.unsafe(children).find { |c| searchable_child_matches(c, name, type) }
end

#find_all(name: nil, type: nil) ⇒ Object

Finds the first child matching the given predicates.

Parameters:

  • name (String, nil) (defaults to: nil)

    The name of the child to filter on, or nil.

  • type (Class, nil) (defaults to: nil)

    The type of the child to filter on, or nil. The type is compared using #is_a?.



34
35
36
# File 'lib/parlour/mixin/searchable.rb', line 34

def find_all(name: nil, type: nil)
  T.unsafe(children).select { |c| searchable_child_matches(c, name, type) }
end