Class: ActiveCortex::Generator::Boolean

Inherits:
ActiveCortex::Generator show all
Defined in:
lib/active_cortex/generator/boolean.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

#initialize, #save_generation

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/boolean.rb', line 2

def self.accepts?(record:, field_name:)
  record.class.attribute_types[field_name.to_s].type == :boolean
end

.generate(record:, field_name:) ⇒ Object



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

def self.generate(record:, field_name:)
  record.send("#{field_name}=", generation)
end

Instance Method Details

#generationObject



10
11
12
# File 'lib/active_cortex/generator/boolean.rb', line 10

def generation
  openai_content || raise(ActiveCortex::Error, openai_error_message)
end