Class: TableHelper::Row
- Inherits:
-
HtmlElement
- Object
- HtmlElement
- TableHelper::Row
- Defined in:
- lib/table_helper/row.rb
Overview
Represents a single row within a table. A row can consist of either data cells or header cells.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#builder ⇒ Object
readonly
The proxy class used externally to build the actual cells.
-
#cells ⇒ Object
readonly
The current cells in this row, in the order in which they will be built.
-
#parent ⇒ Object
readonly
The parent element for this row.
Instance Method Summary collapse
-
#cell(name, *args) ⇒ Object
Creates a new cell with the given name and generates shortcut accessors for the method.
-
#cell_names ⇒ Object
The names of all cells in this row.
-
#clear ⇒ Object
Clears all of the current cells from the row.
-
#initialize(parent) ⇒ Row
constructor
:nodoc:.
Methods inherited from HtmlElement
Constructor Details
#initialize(parent) ⇒ Row
:nodoc:
65 66 67 68 69 70 71 |
# File 'lib/table_helper/row.rb', line 65 def initialize(parent) #:nodoc: super() @parent = parent @cells = ActiveSupport::OrderedHash.new @builder = RowBuilder.new(self) end |
Instance Attribute Details
#builder ⇒ Object (readonly)
The proxy class used externally to build the actual cells
54 55 56 |
# File 'lib/table_helper/row.rb', line 54 def builder @builder end |
#cells ⇒ Object (readonly)
The current cells in this row, in the order in which they will be built
57 58 59 |
# File 'lib/table_helper/row.rb', line 57 def cells @cells end |
#parent ⇒ Object (readonly)
The parent element for this row
60 61 62 |
# File 'lib/table_helper/row.rb', line 60 def parent @parent end |
Instance Method Details
#cell(name, *args) ⇒ Object
Creates a new cell with the given name and generates shortcut accessors for the method.
75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/table_helper/row.rb', line 75 def cell(name, *args) name = name.to_s if name = args.last.is_a?(Hash) ? args.pop : {} [:namespace] = table.object_name args << cell = Cell.new(name, *args) cells[name] = cell builder.define_cell(name) if name cell end |
#cell_names ⇒ Object
The names of all cells in this row
90 91 92 |
# File 'lib/table_helper/row.rb', line 90 def cell_names cells.keys end |
#clear ⇒ Object
Clears all of the current cells from the row
95 96 97 98 99 |
# File 'lib/table_helper/row.rb', line 95 def clear # Remove all of the shortcut methods cell_names.each {|name| builder.undef_cell(name)} cells.clear end |