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, template) ⇒ Renderer
constructor
A new instance of Renderer.
- #options(instance) ⇒ Object
- #render(instance) ⇒ Object
Constructor Details
#initialize(row, template) ⇒ Renderer
Returns a new instance of Renderer.
18 19 20 |
# File 'lib/trestle/table/row.rb', line 18 def initialize(row, template) @row, @template = row, template end |
Instance Method Details
#columns ⇒ Object
22 23 24 |
# File 'lib/trestle/table/row.rb', line 22 def columns table.columns.map { |column| column.renderer(@template) }.select(&:render?) end |
#options(instance) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# 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: { url: admin_url_for(instance) }) .merge!(data: { behavior: "dialog" }) if table.admin.form.dialog? 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.content_tag(:tr, (instance)) do @template.safe_join(columns.map { |column| column.render(instance) }, "\n") end end |