Class: RailsAiBridge::Serializers::Providers::Collaborators::RulesModelSectionBuilder
- Inherits:
-
Object
- Object
- RailsAiBridge::Serializers::Providers::Collaborators::RulesModelSectionBuilder
- 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
-
#call ⇒ Array<String>
Model-section lines or an empty array when models are unavailable.
-
#initialize(models:, config:) ⇒ RulesModelSectionBuilder
constructor
A new instance of RulesModelSectionBuilder.
Constructor Details
#initialize(models:, config:) ⇒ RulesModelSectionBuilder
Returns a new instance of RulesModelSectionBuilder.
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
#call ⇒ Array<String>
Returns 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 |