Class: DryCrud::Table::Col

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/dry_crud/table/col.rb

Overview

Helper class to store column information.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(header, html_options, template, block) ⇒ Col

Returns a new instance of Col.


11
12
13
14
15
16
# File 'app/helpers/dry_crud/table/col.rb', line 11

def initialize(header, html_options, template, block)
  @header = header
  @html_options = html_options
  @template = template
  @block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block


9
10
11
# File 'app/helpers/dry_crud/table/col.rb', line 9

def block
  @block
end

#headerObject (readonly)

Returns the value of attribute header


9
10
11
# File 'app/helpers/dry_crud/table/col.rb', line 9

def header
  @header
end

#html_optionsObject (readonly)

Returns the value of attribute html_options


9
10
11
# File 'app/helpers/dry_crud/table/col.rb', line 9

def html_options
  @html_options
end

#templateObject (readonly)

Returns the value of attribute template


9
10
11
# File 'app/helpers/dry_crud/table/col.rb', line 9

def template
  @template
end

Instance Method Details

#content(entry) ⇒ Object

Runs the Col block for the given entry.


19
20
21
# File 'app/helpers/dry_crud/table/col.rb', line 19

def content(entry)
  entry.nil? ? '' : capture(entry, &block)
end

#html_cell(entry) ⇒ Object

Renders a table cell for the given entry.


29
30
31
# File 'app/helpers/dry_crud/table/col.rb', line 29

def html_cell(entry)
  tag.td(content(entry), **html_options)
end

#html_headerObject

Renders the header cell of the Col.


24
25
26
# File 'app/helpers/dry_crud/table/col.rb', line 24

def html_header
  tag.th(header, **html_options)
end