Class: RailsAiBridge::Tools::ModelDetails::FullFormatter
- Inherits:
-
Object
- Object
- RailsAiBridge::Tools::ModelDetails::FullFormatter
- Defined in:
- lib/rails_ai_bridge/tools/model_details/full_formatter.rb
Overview
Renders ActiveRecord model names with table names, tiers, and full association lists.
Instance Method Summary collapse
-
#call ⇒ String
Builds Markdown with header
# Models (N)and detailed bullets per model, plus optional POJO appendix. -
#initialize(models:, non_ar_models: nil) ⇒ FullFormatter
constructor
A new instance of FullFormatter.
Constructor Details
#initialize(models:, non_ar_models: nil) ⇒ FullFormatter
Returns a new instance of FullFormatter.
10 11 12 13 |
# File 'lib/rails_ai_bridge/tools/model_details/full_formatter.rb', line 10 def initialize(models:, non_ar_models: nil) @models = models @non_ar_models = non_ar_models end |
Instance Method Details
#call ⇒ String
Builds Markdown with header # Models (N) and detailed bullets per model, plus optional POJO appendix.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rails_ai_bridge/tools/model_details/full_formatter.rb', line 18 def call lines = ["# Models (#{@models.size})", ''] @models.keys.sort.each do |name| data = @models[name] next if data[:error] assocs = (data[:associations] || []).map do |a| ConfidenceTag.tagged("#{a[:type]} :#{a[:name]}", a[:source] || :reflection) end.join(', ') line = "- **#{name}**" line += " (table: #{data[:table_name]})" if data[:table_name] line += " — tier: #{data[:semantic_tier]}" if data[:semantic_tier].present? line += " — #{assocs}" unless assocs.empty? lines << line end lines << '' << '_Use `model:"Name"` for validations, scopes, callbacks, and more._' lines.join("\n") + NonArModelsAppendix.append_markdown(@non_ar_models) end |