Class: PaginatedTable::TableDescription

Inherits:
Object
  • Object
show all
Defined in:
lib/paginated_table/table_description.rb

Defined Under Namespace

Classes: Invalid

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options = {}, description_proc = nil)
  @options = options
  @columns = []
  @rows = []
  description_proc.call(self) if description_proc
end

Instance Attribute Details

#columnsObject (readonly)

Returns the value of attribute columns.



3
4
5
# File 'lib/paginated_table/table_description.rb', line 3

def columns
  @columns
end

#rowsObject (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

Raises:

  • (ArgumentError)


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

Raises:



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_labelObject



27
28
29
# File 'lib/paginated_table/table_description.rb', line 27

def model_label
  @options.fetch(:model_label, false)
end

#row(options = {}, &block) ⇒ Object



12
13
14
15
# File 'lib/paginated_table/table_description.rb', line 12

def row(options = {}, &block)
  @explicit_rows = true
  create_row(options, block)
end