Class: CafeCar::Table::HeadBuilder
- Inherits:
-
ObjectsBuilder
- Object
- Builder
- ObjectsBuilder
- CafeCar::Table::HeadBuilder
- Defined in:
- lib/cafe_car/table/head_builder.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
Attributes inherited from Builder
Instance Method Summary collapse
- #cell(method, *flags, label: label(method)) ⇒ Object
- #controls ⇒ Object
-
#initialize ⇒ HeadBuilder
constructor
A new instance of HeadBuilder.
- #label(method) ⇒ Object
- #to_html ⇒ Object
Methods inherited from ObjectsBuilder
Methods inherited from Builder
#has?, #html_safe?, #logo, #model_name, #remaining, #remaining_attributes, #shown, #shown!, #timestamp_attribute, #timestamps, #title, #to_s, #~@
Methods included from OptionHelpers
#assign_option!, #assign_options!, #get_options
Methods included from ProcHelpers
Constructor Details
#initialize ⇒ HeadBuilder
Returns a new instance of HeadBuilder.
5 6 7 8 |
# File 'lib/cafe_car/table/head_builder.rb', line 5 def initialize(...) @fields = [] super end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
3 4 5 |
# File 'lib/cafe_car/table/head_builder.rb', line 3 def fields @fields end |
Instance Method Details
#cell(method, *flags, label: label(method)) ⇒ Object
10 11 12 13 14 |
# File 'lib/cafe_car/table/head_builder.rb', line 10 def cell(method, *flags, label: label(method), **, &) super @fields << model.info.field(method) ui.Cell(*flags) { label } end |
#controls ⇒ Object
22 |
# File 'lib/cafe_car/table/head_builder.rb', line 22 def controls(*, **) = cell(:controls, :controls, *, label: nil, **) |
#label(method) ⇒ Object
16 17 18 19 20 |
# File 'lib/cafe_car/table/head_builder.rb', line 16 def label(method) l = LabelBuilder.new(@template, objects: @objects, method:) @objects.includes!(method) if l.association? l end |
#to_html ⇒ Object
24 |
# File 'lib/cafe_car/table/head_builder.rb', line 24 def to_html = ui.Head(:sticky) { capture(self, &@block) } |