Class: TableSettings::Row

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(row_id) ⇒ Row

Returns a new instance of Row.



57
58
59
60
# File 'lib/table_settings/table_button.rb', line 57

def initialize(row_id)
  @id = row_id
  @buttons = []
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



55
56
57
# File 'lib/table_settings/table_button.rb', line 55

def id
  @id
end

Instance Method Details

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

Yields:

  • (button)


62
63
64
65
66
67
# File 'lib/table_settings/table_button.rb', line 62

def add_button(label, url_path = nil)
  button = TableSettings::Button.new(@id, label, url_path)
  yield(button) if block_given?
  @buttons << button
  button
end

#dataObject



69
70
71
72
73
74
75
76
77
78
# File 'lib/table_settings/table_button.rb', line 69

def data
  if @buttons.empty?
    {}
  elsif @buttons.size == 1
    @buttons[0].hash
  else  @buttons.size > 1
    @buttons.collect { |button| button.hash }
  end

end