Class: Glib::JsonUi::ListBuilders::Section

Inherits:
AbstractBuilder show all
Defined in:
app/helpers/glib/json_ui/list_builders.rb

Instance Attribute Summary

Attributes inherited from AbstractBuilder

#json, #page

Instance Method Summary collapse

Constructor Details

#initialize(json, page, template) ⇒ Section

Returns a new instance of Section.



80
81
82
83
# File 'app/helpers/glib/json_ui/list_builders.rb', line 80

def initialize(json, page, template)
  super json, page
  @template = template
end

Instance Method Details



104
105
106
107
108
# File 'app/helpers/glib/json_ui/list_builders.rb', line 104

def footer(options = {})
  json.footer do
    page.vertical_content(options)
  end
end

#header(options = {}) ⇒ Object



85
86
87
88
89
# File 'app/helpers/glib/json_ui/list_builders.rb', line 85

def header(options = {})
  json.header do
    page.vertical_content(options)
  end
end

#rows(options = {}) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
# File 'app/helpers/glib/json_ui/list_builders.rb', line 91

def rows(options = {})
  block = options[:builder]
  json.rows do
    if (objects = options[:objects])
      objects.each_with_index do |object, index|
        block&.call @template, object, index
      end
    else
      block&.call @template
    end
  end
end