Class: CafeCar::Table::HeadBuilder

Inherits:
ObjectsBuilder show all
Defined in:
lib/cafe_car/table/head_builder.rb

Instance Attribute Summary collapse

Attributes inherited from Builder

#ui

Instance Method Summary collapse

Methods inherited from ObjectsBuilder

#model, #policy

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

#call_procs!, #clone_or_call!

Constructor Details

#initializeHeadBuilder

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

#fieldsObject (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

#controlsObject



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_htmlObject



24
# File 'lib/cafe_car/table/head_builder.rb', line 24

def to_html = ui.Head(:sticky) { capture(self, &@block) }