Class: RailsAiBridge::Serializers::Formatters::Sections::SectionFormatter
- Defined in:
- lib/rails_ai_bridge/serializers/formatters/sections/section_formatter.rb
Overview
Template-method base for section formatters that follow the standard guard pattern: extract data by key, return nil when absent or errored, then delegate to #render.
Subclasses declare their context key with +section+ and implement +render(data)+:
class SchemaFormatter < Formatters::Sections::SectionFormatter section :schema
private
def render(data)
# build and return markdown string, or nil
end
end
Direct Known Subclasses
ActionMailboxFormatter, ActionTextFormatter, ActiveStorageFormatter, ApiFormatter, AppOverviewFormatter, AssetsFormatter, AuthFormatter, ConfigFormatter, ControllersFormatter, ConventionsFormatter, DevopsFormatter, EnginesFormatter, GemsFormatter, I18nFormatter, JobsFormatter, MiddlewareFormatter, MigrationsFormatter, ModelsFormatter, MultiDatabaseFormatter, RakeTasksFormatter, RoutesFormatter, SchemaFormatter, SeedsFormatter, TestsFormatter, TurboFormatter, ViewsFormatter
Class Attribute Summary collapse
-
.section_key ⇒ Symbol
readonly
The context key this formatter reads from.
Attributes inherited from Base
Instance Method Summary collapse
-
#call ⇒ String?
Extracts data from +context[section_key]+, applies standard guards, and delegates to #render.
Methods inherited from Base
Constructor Details
This class inherits a constructor from RailsAiBridge::Serializers::Formatters::Base
Class Attribute Details
.section_key ⇒ Symbol (readonly)
Returns the context key this formatter reads from.
27 28 29 |
# File 'lib/rails_ai_bridge/serializers/formatters/sections/section_formatter.rb', line 27 def section_key @section_key end |
Instance Method Details
#call ⇒ String?
Extracts data from +context[section_key]+, applies standard guards, and delegates to #render.
43 44 45 46 47 48 49 |
# File 'lib/rails_ai_bridge/serializers/formatters/sections/section_formatter.rb', line 43 def call data = context[self.class.section_key] return unless data return if data[:error] render(data) end |