Class: Katalyst::Tables::RowRenderer

Inherits:
ActionView::PartialRenderer
  • Object
show all
Includes:
ObjectRendering
Defined in:
app/components/concerns/katalyst/tables/row_renderer.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(lookup_context, collection:, partial:, **options) ⇒ RowRenderer

Returns a new instance of RowRenderer.



8
9
10
11
12
13
# File 'app/components/concerns/katalyst/tables/row_renderer.rb', line 8

def initialize(lookup_context, collection:, partial:, **options)
  super(lookup_context, options)

  @collection = collection
  @partial    = partial
end

Instance Method Details

#render_row(row, object, view_context) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/components/concerns/katalyst/tables/row_renderer.rb', line 15

def render_row(row, object, view_context)
  @row    = row
  @object = object

  if @partial.blank?
    example  = example_for(@collection)
    @partial = partial_path(example, view_context) if example.present?
  end

  # if we still cannot find an example return an empty table (no header row)
  return "" if @partial.blank?

  @local_name ||= local_variable(@partial)
  render(@partial, view_context, nil)
end