Class: RailsTableFor::Elements::BlockColumn

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::TagHelper, Column, Helpers::AutoLink
Defined in:
lib/rails_table_for/elements/block_column.rb

Instance Method Summary collapse

Methods included from Column

#th

Methods included from Helpers::AutoLink

#auto_link

Constructor Details

#initialize(block, **options) ⇒ BlockColumn

Returns a new instance of BlockColumn.



16
17
18
19
20
# File 'lib/rails_table_for/elements/block_column.rb', line 16

def initialize(block, **options)
  @block = block
  @title = options[:title]
  @auto_link_enabled = options[:auto_link] || false
end

Instance Method Details

#td(record) ⇒ Object



22
23
24
25
26
# File 'lib/rails_table_for/elements/block_column.rb', line 22

def td(record)
  text = block.call(record)
  content = auto_link_enabled ? auto_link(record, text) : text
   :td, content
end