Class: ActiveCortex::Generator::HasMany

Inherits:
ActiveCortex::Generator show all
Defined in:
lib/active_cortex/generator/has_many.rb

Instance Attribute Summary

Attributes inherited from ActiveCortex::Generator

#field_name, #max_results, #model, #record

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ActiveCortex::Generator

generate, #initialize

Constructor Details

This class inherits a constructor from ActiveCortex::Generator

Class Method Details

.accepts?(record:, field_name:) ⇒ Boolean

Returns:



2
3
4
# File 'lib/active_cortex/generator/has_many.rb', line 2

def self.accepts?(record:, field_name:)
  record.class.reflect_on_association(field_name)&.collection?
end

Instance Method Details

#generationObject



10
11
12
13
14
# File 'lib/active_cortex/generator/has_many.rb', line 10

def generation
  generate_tool_calls.map do |tool_call|
    build_record_from_tool_call(tool_call)
  end
end

#save_generationObject



6
7
8
# File 'lib/active_cortex/generator/has_many.rb', line 6

def save_generation
  record.send(field_name).push(generation)
end