Class: Plutonium::Definition::FormLayout::Builder
- Inherits:
-
Object
- Object
- Plutonium::Definition::FormLayout::Builder
- Defined in:
- lib/plutonium/definition/form_layout.rb
Overview
Collects section/ungrouped calls from a form_layout block in order.
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.
40 41 42 43 |
# File 'lib/plutonium/definition/form_layout.rb', line 40 def initialize @sections = [] @ungrouped_seen = false end |
Instance Attribute Details
#sections ⇒ Object (readonly)
Returns the value of attribute sections.
38 39 40 |
# File 'lib/plutonium/definition/form_layout.rb', line 38 def sections @sections end |
Instance Method Details
#section(key, *fields, **options) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/plutonium/definition/form_layout.rb', line 45 def section(key, *fields, **) if key == UNGROUPED_KEY raise ArgumentError, "`section :#{UNGROUPED_KEY}` is reserved — use the `ungrouped` macro" end validate_columns!() @sections << Section.new(key:, fields: fields.freeze, options: .freeze) end |
#ungrouped(**options) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/plutonium/definition/form_layout.rb', line 54 def ungrouped(**) raise ArgumentError, "`ungrouped` may only be declared once" if @ungrouped_seen @ungrouped_seen = true validate_columns!() @sections << Section.new(key: UNGROUPED_KEY, fields: [].freeze, options: .freeze) end |