Class: CafeCar::Table::RowBuilder
- Inherits:
-
Builder
- Object
- Builder
- CafeCar::Table::RowBuilder
show all
- Defined in:
- lib/cafe_car/table/row_builder.rb
Instance Attribute Summary
Attributes inherited from Builder
#ui
Instance Method Summary
collapse
Methods inherited from Builder
#has?, #html_safe?, #initialize, #logo, #model_name, #remaining, #remaining_attributes, #shown, #shown!, #timestamp_attribute, #title, #to_s, #~@
#assign_option!, #assign_options!, #get_options
#call_procs!, #clone_or_call!
Instance Method Details
#cell(method, *flags, **options) ⇒ Object
19
20
21
22
23
24
|
# File 'lib/cafe_car/table/row_builder.rb', line 19
def cell(method, *flags, **options, &)
super
options[:href] = @object if options[:href] == true
call_procs!(options, @object)
ui.Cell(*flags, **options) { show(method, **options.slice(:blank), &) }
end
|
#controls(*args, **options) ⇒ Object
31
32
33
|
# File 'lib/cafe_car/table/row_builder.rb', line 31
def controls(*args, **options)
ui.Cell(:shrink, :shy, :controls, *args) { present(@object).controls(*args, **options) }
end
|
#href ⇒ Object
12
|
# File 'lib/cafe_car/table/row_builder.rb', line 12
def href = @href
|
#href! ⇒ Object
5
6
7
8
9
10
|
# File 'lib/cafe_car/table/row_builder.rb', line 5
def href!
@href = @options.delete(:href) { true }
@href = @href.to_proc.(@object) if @href.respond_to?(:to_proc)
@href = nil if @href == false
end
|
#model ⇒ Object
13
|
# File 'lib/cafe_car/table/row_builder.rb', line 13
def model = @object.class
|
#policy(o = @object) ⇒ Object
14
|
# File 'lib/cafe_car/table/row_builder.rb', line 14
def policy(o = @object) = @template.policy(o)
|
#show ⇒ Object
17
|
# File 'lib/cafe_car/table/row_builder.rb', line 17
def show(...) = present(@object).show(...)
|
#timestamps(**options) ⇒ Object
26
27
28
29
|
# File 'lib/cafe_car/table/row_builder.rb', line 26
def timestamps(**options)
tip = show(:created_at).string&.then { "Created: #{_1}" }
cell(timestamp_attribute, :shrink, tip:, **options)
end
|
#to_html ⇒ Object
35
36
37
|
# File 'lib/cafe_car/table/row_builder.rb', line 35
def to_html
ui.Row { safe_join [ capture(self, &@block), @template.turbo_stream_from(@object) ] }
end
|
#value(method) ⇒ Object
16
|
# File 'lib/cafe_car/table/row_builder.rb', line 16
def value(method) = @object.try(method)
|