Class: Mensa::Cell

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::SanitizeHelper, ActionView::Helpers::TagHelper, ActionView::Helpers::UrlHelper, ApplicationHelper
Defined in:
app/tables/mensa/cell.rb,
app/components/mensa/cell/component.rb

Defined Under Namespace

Classes: Component

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(row:, column:) ⇒ Cell

Returns a new instance of Cell.



13
14
15
16
# File 'app/tables/mensa/cell.rb', line 13

def initialize(row:, column:)
  @row = row
  @column = column
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



11
12
13
# File 'app/tables/mensa/cell.rb', line 11

def column
  @column
end

#rowObject (readonly)

Returns the value of attribute row.



11
12
13
# File 'app/tables/mensa/cell.rb', line 11

def row
  @row
end

Instance Method Details

#render(format) ⇒ Object



22
23
24
25
26
27
28
29
# File 'app/tables/mensa/cell.rb', line 22

def render(format)
  proc = column.config.dig(:render, format.to_sym)
  if proc
    row.table.original_view_context.instance_exec(row.record, &proc)
  else
    send("to_#{format}".to_sym)
  end
end

#valueObject



18
19
20
# File 'app/tables/mensa/cell.rb', line 18

def value
  @value ||= row.value(column)
end