Class: RailsAiBridge::Serializers::Providers::Collaborators::RulesModelSectionBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_ai_bridge/serializers/providers/collaborators/rules_model_section_builder.rb

Overview

Builds the compact models section used by split rules serializers.

Defined Under Namespace

Classes: ModelEntry

Constant Summary collapse

SECTION_HEADER_FORMAT =

Format string for the model section heading.

'## Models (%d total)'
MODEL_ENTRY_FORMAT =

Format string for one model summary row.

'- %s (%d associations)'
MODELS_OVERFLOW_FORMAT =

Format string for the overflow hint when not all models fit.

'- _...%d more — `rails_get_model_details(detail:"summary")`._'
MODELS_LIMIT_ZERO_FORMAT =

Message shown when the configured model list limit is zero or negative.

'- _Use `rails_get_model_details(detail:"summary")` for names._'

Instance Method Summary collapse

Constructor Details

#initialize(models:, config:) ⇒ RulesModelSectionBuilder

Returns a new instance of RulesModelSectionBuilder.

Parameters:



23
24
25
26
# File 'lib/rails_ai_bridge/serializers/providers/collaborators/rules_model_section_builder.rb', line 23

def initialize(models:, config:)
  @models = models
  @config = config
end

Instance Method Details

#callArray<String>

Returns model-section lines or an empty array when models are unavailable.

Returns:

  • (Array<String>)

    model-section lines or an empty array when models are unavailable



29
30
31
32
33
34
35
# File 'lib/rails_ai_bridge/serializers/providers/collaborators/rules_model_section_builder.rb', line 29

def call
  return [] unless valid_models?

  lines = [format(SECTION_HEADER_FORMAT, @models.size)]
  model_list_limit.positive? ? add_model_entries(lines) : lines << MODELS_LIMIT_ZERO_FORMAT
  lines << ''
end