Class: DocsUI::FieldTable

Inherits:
Phlex::HTML
  • Object
show all
Defined in:
app/components/docs_ui/field_table.rb

Overview

A parameter/field reference table for an API object or request body — a keyword-schema preset over DocsUI::Table. Each field is a Hash:

render DocsUI::FieldTable.new(
[
  { name: "url",         type: "string", required: true, description: "HTTPS destination URL." },
  { name: "description", type: "string",                 description: "Optional internal label." },
  { name: "events",      type: "array",  required: true, description: [:md, "e.g. `payment_link.paid`"] },
]
)

Columns: Name (auto code-styled) / Type / Required (✓ or the canonical em-dash ) / Description. required: defaults to false. The description cell follows DocsUI::Table's convention — a plain String is escaped text, [:code, "x"] is inline code, [:md, "…"] is inline Markdown.

Constant Summary collapse

HEADERS =
%w[Name Type Required Description].freeze
REQUIRED_YES =

The ONE canonical "no value" placeholder across the whole kit — never the ASCII hyphen "-", never a bare "—" typed ad hoc in a page.

""
REQUIRED_NO =
""

Instance Method Summary collapse

Constructor Details

#initialize(fields) ⇒ FieldTable

Returns a new instance of FieldTable.



27
28
29
# File 'app/components/docs_ui/field_table.rb', line 27

def initialize(fields)
  @fields = fields
end

Instance Method Details

#view_templateObject



31
32
33
# File 'app/components/docs_ui/field_table.rb', line 31

def view_template
  render DocsUI::Table.new(HEADERS, @fields.map { |field| row(field) })
end