Class: Tubular::Column
- Inherits:
-
Object
- Object
- Tubular::Column
- Defined in:
- lib/tubular/column.rb
Instance Attribute Summary collapse
-
#cell_content ⇒ Object
readonly
Returns the value of attribute cell_content.
-
#cell_html ⇒ Object
readonly
Returns the value of attribute cell_html.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#header_content ⇒ Object
readonly
Returns the value of attribute header_content.
-
#header_html ⇒ Object
readonly
Returns the value of attribute header_html.
-
#method_name ⇒ Object
readonly
Returns the value of attribute method_name.
Instance Method Summary collapse
-
#initialize(context, *args, &block) ⇒ Column
constructor
A new instance of Column.
- #render_body_content(record) ⇒ Object
- #render_header_content ⇒ Object
Constructor Details
#initialize(context, *args, &block) ⇒ Column
Returns a new instance of Column.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/tubular/column.rb', line 9 def initialize(context, *args, &block) attributes = args. @context = context @method_name = attributes.fetch(:method_name, args.shift) @header_html = attributes.fetch(:header_html, {}) @header_content = attributes.fetch(:header_content, nil) @cell_html = attributes.fetch(:cell_html, {}) @cell_content = attributes.fetch(:cell_content, nil) if block_given? @cell_content = block end end |
Instance Attribute Details
#cell_content ⇒ Object (readonly)
Returns the value of attribute cell_content.
4 5 6 |
# File 'lib/tubular/column.rb', line 4 def cell_content @cell_content end |
#cell_html ⇒ Object (readonly)
Returns the value of attribute cell_html.
4 5 6 |
# File 'lib/tubular/column.rb', line 4 def cell_html @cell_html end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
4 5 6 |
# File 'lib/tubular/column.rb', line 4 def context @context end |
#header_content ⇒ Object (readonly)
Returns the value of attribute header_content.
4 5 6 |
# File 'lib/tubular/column.rb', line 4 def header_content @header_content end |
#header_html ⇒ Object (readonly)
Returns the value of attribute header_html.
4 5 6 |
# File 'lib/tubular/column.rb', line 4 def header_html @header_html end |
#method_name ⇒ Object (readonly)
Returns the value of attribute method_name.
4 5 6 |
# File 'lib/tubular/column.rb', line 4 def method_name @method_name end |
Instance Method Details
#render_body_content(record) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/tubular/column.rb', line 35 def render_body_content(record) case cell_content when Proc call_content_proc(cell_content, record) when NilClass method_name && record.respond_to?(method_name) ? record.send(method_name) : nil else cell_content.to_s end end |
#render_header_content ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tubular/column.rb', line 24 def render_header_content case header_content when Proc header_content.call when String, Symbol t(header_content) when NilClass method_name ? t(method_name) : nil end end |