Class: LightGptProxy::Config
- Inherits:
-
Object
- Object
- LightGptProxy::Config
show all
- Defined in:
- lib/light_gpt_proxy/config.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data) ⇒ Config
Returns a new instance of Config.
5
6
7
8
9
|
# File 'lib/light_gpt_proxy/config.rb', line 5
def initialize(data)
raise ArgumentError, 'Config data must be a Hash' unless data.is_a?(Hash)
@data = data
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args) ⇒ Object
30
31
32
33
34
35
|
# File 'lib/light_gpt_proxy/config.rb', line 30
def method_missing(symbol, *args)
key = symbol.to_s
return data[key] if data.key?(key)
super
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
11
12
13
|
# File 'lib/light_gpt_proxy/config.rb', line 11
def data
@data
end
|
Instance Method Details
#provider(name) ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/light_gpt_proxy/config.rb', line 19
def provider(name)
return providers_instances[name] if providers_instances[name]
provider_data = data['providers']&.fetch(name, nil)
raise ArgumentError, "Provider '#{name}' not found" unless provider_data
providers_instances[name] = Provider.new(name:, config: provider_data)
end
|
#providers ⇒ Object
17
|
# File 'lib/light_gpt_proxy/config.rb', line 17
def providers = data['providers']&.keys || []
|
#providers_instances ⇒ Object
13
14
15
|
# File 'lib/light_gpt_proxy/config.rb', line 13
def providers_instances
@providers_instances ||= {}
end
|