Class: TableSettings::Buttons

Inherits:
Object
  • Object
show all
Defined in:
lib/table_settings/table_button.rb

Instance Method Summary collapse

Constructor Details

#initializeButtons

Returns a new instance of Buttons.



3
4
5
6
# File 'lib/table_settings/table_button.rb', line 3

def initialize()
  @buttons_hash = {}
  @rows = {}
end

Instance Method Details

#add_button(row_id, label, url_path = nil) {|button| ... } ⇒ Object

Yields:

  • (button)


26
27
28
29
30
31
32
33
34
# File 'lib/table_settings/table_button.rb', line 26

def add_button(row_id, label, url_path = nil)
  row = @rows[row_id].nil? ? add_row(row_id) : @rows[row_id]

  button = row.add_button(label, url_path)

  yield(button) if block_given?

  button
end

#add_row(row_id) {|row| ... } ⇒ Object

Yields:

  • (row)


16
17
18
19
20
21
22
23
24
# File 'lib/table_settings/table_button.rb', line 16

def add_row(row_id)
  row = TableSettings::Row.new(row_id)

  yield(row) if block_given?

  @rows[row_id] = row

  row
end

#hashObject



8
9
10
11
12
13
14
# File 'lib/table_settings/table_button.rb', line 8

def hash
  @rows.each_value do |row|
    @buttons_hash[row.id] = row.data
  end

  @buttons_hash
end

#summarize_page_all_value(value) ⇒ Object

Add summary value to whole column Have to set TableSettings::Column.summarize_all



46
47
48
49
50
# File 'lib/table_settings/table_button.rb', line 46

def summarize_page_all_value(value)
  @buttons_hash[:summarize_page_all] = value

  self
end

#summarize_page_value(value) ⇒ Object

Add summary value to page Have to set TableSettings::Column.summarize_page



38
39
40
41
42
# File 'lib/table_settings/table_button.rb', line 38

def summarize_page_value(value)
  @buttons_hash[:summarize_page_value] = value

  self
end