Class: Trestle::Table::Row::Renderer
- Inherits:
-
Object
- Object
- Trestle::Table::Row::Renderer
- Defined in:
- lib/trestle/table/row.rb
Instance Method Summary collapse
- #columns ⇒ Object
-
#initialize(row, table:, template:) ⇒ Renderer
constructor
A new instance of Renderer.
- #options(instance) ⇒ Object
- #render(instance) ⇒ Object
Constructor Details
#initialize(row, table:, template:) ⇒ Renderer
Returns a new instance of Renderer.
16 17 18 |
# File 'lib/trestle/table/row.rb', line 16 def initialize(row, table:, template:) @row, @table, @template = row, table, template end |
Instance Method Details
#columns ⇒ Object
20 21 22 23 24 |
# File 'lib/trestle/table/row.rb', line 20 def columns @table.columns.map { |column| column.renderer(table: @table, template: @template) }.select(&:render?) end |
#options(instance) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/trestle/table/row.rb', line 32 def (instance) = Trestle::Options.new if @table.admin && @table.autolink? && @table.admin.actions.include?(:show) .merge!(data: { controller: "follow-url", action: "click->follow-url#follow" }) .merge!(data: { url: admin_url_for(instance) }) .merge!(data: { modal: true }) if @table.admin.form.modal? end .merge!(@row.) .merge!(@template.instance_exec(instance, &@row.block)) if @row.block end |
#render(instance) ⇒ Object
26 27 28 29 30 |
# File 'lib/trestle/table/row.rb', line 26 def render(instance) @template.tag.tr(**(instance)) do @template.safe_join(columns.map { |column| column.render(instance) }, "\n") end end |