Class: Nanobot::Config::ProvidersConfig
- Inherits:
-
Object
- Object
- Nanobot::Config::ProvidersConfig
- Defined in:
- lib/nanobot/config/schema.rb
Overview
Collection of LLM provider configurations, keyed by provider name. Accepts any provider name so new RubyLLM backends work without code changes.
Instance Method Summary collapse
-
#each {|key, config| ... } ⇒ Object
Iterate over all configured providers.
-
#empty? ⇒ Boolean
True when no providers are configured.
-
#initialize(**kwargs) ⇒ ProvidersConfig
constructor
A new instance of ProvidersConfig.
- #method_missing(name, *args) ⇒ Object
- #respond_to_missing?(_name, _include_private = false) ⇒ Boolean
Constructor Details
#initialize(**kwargs) ⇒ ProvidersConfig
Returns a new instance of ProvidersConfig.
21 22 23 24 25 26 |
# File 'lib/nanobot/config/schema.rb', line 21 def initialize(**kwargs) @providers = {} kwargs.each do |key, value| @providers[key.to_sym] = value.is_a?(ProviderConfig) ? value : ProviderConfig.new(**value) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
44 45 46 47 48 |
# File 'lib/nanobot/config/schema.rb', line 44 def method_missing(name, *args) return super if name.end_with?('=') || !args.empty? @providers[name.to_sym] end |
Instance Method Details
#each {|key, config| ... } ⇒ Object
Iterate over all configured providers
31 32 33 |
# File 'lib/nanobot/config/schema.rb', line 31 def each(&) @providers.each(&) end |
#empty? ⇒ Boolean
Returns true when no providers are configured.
36 37 38 |
# File 'lib/nanobot/config/schema.rb', line 36 def empty? @providers.empty? end |
#respond_to_missing?(_name, _include_private = false) ⇒ Boolean
40 41 42 |
# File 'lib/nanobot/config/schema.rb', line 40 def respond_to_missing?(_name, _include_private = false) true end |