Class: Docscribe::Types::ProviderChain
- Inherits:
-
Object
- Object
- Docscribe::Types::ProviderChain
- Defined in:
- lib/docscribe/types/provider_chain.rb
Overview
Resolve method signatures by querying a list of providers in order.
The first provider that returns a non-nil signature wins.
This lets Docscribe combine multiple external type sources behind one interface, for example:
-
inline Sorbet signatures in the current file
-
Sorbet RBI files
-
RBS files
Instance Method Summary collapse
- #initialize(*providers) ⇒ Object constructor
-
#signature_for(container:, scope:, name:) ⇒ Docscribe::Types::MethodSignature?
Resolve a method signature from the first provider that can supply it.
Constructor Details
#initialize(*providers) ⇒ Object
17 18 19 |
# File 'lib/docscribe/types/provider_chain.rb', line 17 def initialize(*providers) @providers = providers.compact end |
Instance Method Details
#signature_for(container:, scope:, name:) ⇒ Docscribe::Types::MethodSignature?
Resolve a method signature from the first provider that can supply it.
27 28 29 30 31 32 33 34 |
# File 'lib/docscribe/types/provider_chain.rb', line 27 def signature_for(container:, scope:, name:) @providers.each do |provider| sig = provider.signature_for(container: container, scope: scope, name: name) return sig if sig end nil end |