Class: Glib::JsonUi::TableBuilders::Section
- Inherits:
-
AbstractBuilder
- Object
- AbstractBuilder
- Glib::JsonUi::TableBuilders::Section
- Defined in:
- app/helpers/glib/json_ui/table_builders.rb
Instance Attribute Summary
Attributes inherited from AbstractBuilder
Instance Method Summary collapse
- #header(options = {}) ⇒ Object
-
#initialize(json, page, template) ⇒ Section
constructor
A new instance of Section.
- #rows(options = {}) ⇒ Object
Constructor Details
#initialize(json, page, template) ⇒ Section
Returns a new instance of Section.
29 30 31 32 |
# File 'app/helpers/glib/json_ui/table_builders.rb', line 29 def initialize(json, page, template) super json, page @template = template end |
Instance Method Details
#header(options = {}) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/helpers/glib/json_ui/table_builders.rb', line 34 def header( = {}) json.header do json.backgroundColor .delete(:backgroundColor) json.cellViews do .delete(:cellViews)&.call page.view_builder end json.colSpans .delete(:colSpans) end raise "Invalid properties: #{.keys}" if .size > 0 end |
#rows(options = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/helpers/glib/json_ui/table_builders.rb', line 47 def rows( = {}) block = .delete(:builder) json.rows do if (objects = .delete(:objects)) objects.each_with_index do |object, index| block&.call @template, object, index end else block&.call @template end end raise "Invalid properties: #{.keys}" if .size > 0 end |