Class: RbsActivesupport::MethodSearcher

Inherits:
Object
  • Object
show all
Defined in:
lib/rbs_activesupport/method_searcher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rbs_builder) ⇒ MethodSearcher

Returns a new instance of MethodSearcher.



10
11
12
# File 'lib/rbs_activesupport/method_searcher.rb', line 10

def initialize(rbs_builder) #: void
  @rbs_builder = rbs_builder
end

Instance Attribute Details

#rbs_builderObject (readonly)

: RBS::DefinitionBuilder



7
8
9
# File 'lib/rbs_activesupport/method_searcher.rb', line 7

def rbs_builder
  @rbs_builder
end

Instance Method Details

#method_types_for(delegate) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/rbs_activesupport/method_searcher.rb', line 15

def method_types_for(delegate) #: Array[String]
  delegate_to = lookup_method_types(delegate.namespace.to_type_name, delegate.to)
  return ["() -> untyped"] if delegate_to.any? { |t| t.type.return_type.is_a?(RBS::Types::Bases::Any) }

  return_types = return_type_names_for(delegate_to).uniq
                                                   .flat_map { |t| lookup_method_types(t, delegate.method) }
                                                   .map(&:to_s)
  return_types << "() -> untyped" if return_types.empty?
  return_types
end