Module: LlmGateway::FluentMapper
Defined Under Namespace
Classes: MapperDefinition, MapperInstance
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.extended(base) ⇒ Object
5
6
7
8
|
# File 'lib/llm_gateway/fluent_mapper.rb', line 5
def self.extended(base)
base.instance_variable_set(:@mappers, {})
base.instance_variable_set(:@mappings, [])
end
|
Instance Method Details
#inherited(subclass) ⇒ Object
10
11
12
13
14
15
|
# File 'lib/llm_gateway/fluent_mapper.rb', line 10
def inherited(subclass)
super
subclass.instance_variable_set(:@mappers, @mappers.dup)
subclass.instance_variable_set(:@mappings, @mappings.dup)
end
|
#map(field_or_data, options = {}, &block) ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'lib/llm_gateway/fluent_mapper.rb', line 21
def map(field_or_data, options = {}, &block)
if block.nil? && options.empty? && !field_or_data.is_a?(Symbol) && !field_or_data.is_a?(String)
return new(field_or_data).call
end
@mappings << { field: field_or_data, options: options, block: block }
end
|
#mapper(name, &block) ⇒ Object
17
18
19
|
# File 'lib/llm_gateway/fluent_mapper.rb', line 17
def mapper(name, &block)
@mappers[name] = block
end
|
#new(data) ⇒ Object
31
32
33
|
# File 'lib/llm_gateway/fluent_mapper.rb', line 31
def new(data)
MapperInstance.new(data, @mappers, @mappings)
end
|