Class: LightGptProxy::Template
- Inherits:
-
Object
- Object
- LightGptProxy::Template
show all
- Defined in:
- lib/light_gpt_proxy/templates/template.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(**params) ⇒ Template
Returns a new instance of Template.
12
13
14
15
16
|
# File 'lib/light_gpt_proxy/templates/template.rb', line 12
def initialize(**params)
@params = params
validate_params!
@attributes = self.class.optional.merge(params)
end
|
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
18
19
20
|
# File 'lib/light_gpt_proxy/templates/template.rb', line 18
def attributes
@attributes
end
|
#params ⇒ Object
Returns the value of attribute params.
18
19
20
|
# File 'lib/light_gpt_proxy/templates/template.rb', line 18
def params
@params
end
|
Class Method Details
.optional ⇒ Object
10
|
# File 'lib/light_gpt_proxy/templates/template.rb', line 10
def self.optional = {}.freeze
|
.required ⇒ Object
9
|
# File 'lib/light_gpt_proxy/templates/template.rb', line 9
def self.required = raise(NotImplementedError)
|
.template ⇒ Object
8
|
# File 'lib/light_gpt_proxy/templates/template.rb', line 8
def self.template = raise(NotImplementedError)
|
Instance Method Details
#save(path:) ⇒ Object
20
|
# File 'lib/light_gpt_proxy/templates/template.rb', line 20
def save(path:) = File.write(path, to_yaml)
|
#to_h ⇒ Object
21
|
# File 'lib/light_gpt_proxy/templates/template.rb', line 21
def to_h = @to_h ||= YAML.safe_load(to_yaml, permitted_classes: [Symbol])
|
#to_yaml ⇒ Object
22
|
# File 'lib/light_gpt_proxy/templates/template.rb', line 22
def to_yaml = @to_yaml ||= ERB.new(self.class.template.to_yaml).result(binding)
|