Class: PaginatedTable::TableDescription
- Inherits:
-
Object
- Object
- PaginatedTable::TableDescription
- Defined in:
- lib/paginated_table/table_description.rb
Defined Under Namespace
Classes: Invalid
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
- #colspan(span) ⇒ Object
- #column(*args, &block) ⇒ Object
-
#initialize(options = {}, description_proc = nil) ⇒ TableDescription
constructor
A new instance of TableDescription.
- #model_label ⇒ Object
- #row(options = {}, &block) ⇒ Object
Constructor Details
#initialize(options = {}, description_proc = nil) ⇒ TableDescription
Returns a new instance of TableDescription.
5 6 7 8 9 10 |
# File 'lib/paginated_table/table_description.rb', line 5 def initialize( = {}, description_proc = nil) = @columns = [] @rows = [] description_proc.call(self) if description_proc end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
3 4 5 |
# File 'lib/paginated_table/table_description.rb', line 3 def columns @columns end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
3 4 5 |
# File 'lib/paginated_table/table_description.rb', line 3 def rows @rows end |
Instance Method Details
#colspan(span) ⇒ Object
22 23 24 25 |
# File 'lib/paginated_table/table_description.rb', line 22 def colspan(span) raise ArgumentError unless span == :all rows.map { |row| row.columns.length }.max.to_s end |
#column(*args, &block) ⇒ Object
17 18 19 20 |
# File 'lib/paginated_table/table_description.rb', line 17 def column(*args, &block) raise Invalid if @explicit_rows default_row.column(*args, &block) end |
#model_label ⇒ Object
27 28 29 |
# File 'lib/paginated_table/table_description.rb', line 27 def model_label .fetch(:model_label, false) end |
#row(options = {}, &block) ⇒ Object
12 13 14 15 |
# File 'lib/paginated_table/table_description.rb', line 12 def row( = {}, &block) @explicit_rows = true create_row(, block) end |