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) ⇒ void
constructor
Initialize.
-
#signature_for(container:, scope:, name:) ⇒ Docscribe::Types::MethodSignature?
Resolve a method signature from the first provider that can supply it.
Constructor Details
#initialize(*providers) ⇒ void
Initialize
19 20 21 |
# File 'lib/docscribe/types/provider_chain.rb', line 19 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.
29 30 31 32 33 34 35 36 |
# File 'lib/docscribe/types/provider_chain.rb', line 29 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 |