Class: Plutonium::Definition::DisplayLayout::Builder
- Inherits:
-
Object
- Object
- Plutonium::Definition::DisplayLayout::Builder
- Defined in:
- lib/plutonium/definition/display_layout.rb
Overview
Collects section/ungrouped calls from a display_layout block, in order. Builds the same Section struct FormLayout uses — the two layouts share a resolver, so they share a value type.
Instance Attribute Summary collapse
-
#sections ⇒ Object
readonly
Returns the value of attribute sections.
Instance Method Summary collapse
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
- #section(key, *fields, **options) ⇒ Object
- #ungrouped(**options) ⇒ Object
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
39 40 41 42 |
# File 'lib/plutonium/definition/display_layout.rb', line 39 def initialize @sections = [] @ungrouped_seen = false end |
Instance Attribute Details
#sections ⇒ Object (readonly)
Returns the value of attribute sections.
37 38 39 |
# File 'lib/plutonium/definition/display_layout.rb', line 37 def sections @sections end |
Instance Method Details
#section(key, *fields, **options) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/plutonium/definition/display_layout.rb', line 44 def section(key, *fields, **) if key == FormLayout::UNGROUPED_KEY raise ArgumentError, "`section :#{FormLayout::UNGROUPED_KEY}` is reserved — use the `ungrouped` macro" end reject_columns!() @sections << FormLayout::Section.new(key:, fields: fields.freeze, options: .freeze) end |
#ungrouped(**options) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/plutonium/definition/display_layout.rb', line 53 def ungrouped(**) raise ArgumentError, "`ungrouped` may only be declared once" if @ungrouped_seen @ungrouped_seen = true reject_columns!() @sections << FormLayout::Section.new( key: FormLayout::UNGROUPED_KEY, fields: [].freeze, options: .freeze ) end |