Class: TableSettings::Buttons
- Inherits:
-
Object
- Object
- TableSettings::Buttons
- Defined in:
- lib/table_settings/table_button.rb
Instance Method Summary collapse
- #add_button(row_id, label, url_path = nil) {|button| ... } ⇒ Object
- #add_row(row_id) {|row| ... } ⇒ Object
- #hash ⇒ Object
-
#initialize ⇒ Buttons
constructor
A new instance of Buttons.
-
#summarize_page_all_value(value) ⇒ Object
Add summary value to whole column Have to set TableSettings::Column.summarize_all.
-
#summarize_page_value(value) ⇒ Object
Add summary value to page Have to set TableSettings::Column.summarize_page.
Constructor Details
#initialize ⇒ Buttons
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
26 27 28 29 30 31 32 33 34 |
# File 'lib/table_settings/table_button.rb', line 26 def (row_id, label, url_path = nil) row = @rows[row_id].nil? ? add_row(row_id) : @rows[row_id] = row.(label, url_path) yield() if block_given? end |
#add_row(row_id) {|row| ... } ⇒ Object
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 |
#hash ⇒ Object
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 |