Class: RailsAiContext::Introspectors::SchemaIntrospector
- Inherits:
-
Object
- Object
- RailsAiContext::Introspectors::SchemaIntrospector
- Defined in:
- lib/rails_ai_context/introspectors/schema_introspector.rb
Overview
Extracts database schema information including tables, columns, indexes, and foreign keys from the Rails application.
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Instance Method Summary collapse
-
#call ⇒ Hash
Database schema context.
-
#initialize(app) ⇒ SchemaIntrospector
constructor
A new instance of SchemaIntrospector.
Constructor Details
#initialize(app) ⇒ SchemaIntrospector
Returns a new instance of SchemaIntrospector.
10 11 12 |
# File 'lib/rails_ai_context/introspectors/schema_introspector.rb', line 10 def initialize(app) @app = app end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
8 9 10 |
# File 'lib/rails_ai_context/introspectors/schema_introspector.rb', line 8 def app @app end |
Instance Method Details
#call ⇒ Hash
Returns database schema context.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rails_ai_context/introspectors/schema_introspector.rb', line 15 def call return static_schema_parse unless active_record_connected? return static_schema_parse if table_names.empty? schema_content = File.exist?(schema_file_path) ? (RailsAiContext::SafeFile.read(schema_file_path, max_size: RailsAiContext.configuration.max_schema_file_size) || "") : "" { adapter: adapter_name, tables: extract_tables, total_tables: table_names.size, schema_version: current_schema_version, check_constraints: parse_check_constraints(schema_content), enum_types: parse_enum_types(schema_content), generated_columns: parse_generated_columns(schema_content) } end |