Class: RailsAiBridge::Introspectors::ModelIntrospector::AssociationExtractor
- Inherits:
-
Object
- Object
- RailsAiBridge::Introspectors::ModelIntrospector::AssociationExtractor
- Defined in:
- lib/rails_ai_bridge/introspectors/model_introspector/association_extractor.rb
Overview
Extracts association metadata from an ActiveRecord model.
Analyzes ActiveRecord reflections to build a structural representation of the model's associations, including types, classes, foreign keys, and relevant options like polymorphism.
Defined Under Namespace
Classes: DetailBuilder
Instance Method Summary collapse
-
#call ⇒ Array<Hash>
Array of association descriptors.
-
#initialize(model) ⇒ AssociationExtractor
constructor
A new instance of AssociationExtractor.
Constructor Details
#initialize(model) ⇒ AssociationExtractor
Returns a new instance of AssociationExtractor.
51 52 53 |
# File 'lib/rails_ai_bridge/introspectors/model_introspector/association_extractor.rb', line 51 def initialize(model) @model = model end |
Instance Method Details
#call ⇒ Array<Hash>
Returns array of association descriptors.
56 57 58 59 60 61 62 |
# File 'lib/rails_ai_bridge/introspectors/model_introspector/association_extractor.rb', line 56 def call model.reflect_on_all_associations.map do |assoc| DetailBuilder.new(assoc).build end rescue StandardError [] end |