class Data::ButtonBuilder

buttons do |b,r|

b.button :'eye-open', foo_path(r), class: 'btn-success'
b.button :'pencil', edit_foo_path(r), class: 'btn-warning'
b.submenu do |s|
  s.button :star, star_foor_path(r), label: 'Dolle Sache'
  s.divider
  s.button :'trash-o', foo_path(r), label: 'Löschen', confirm: 'echt?', class: 'btn-danger', method: :delete
end

end

Public Class Methods

new() click to toggle source
# File lib/tabulatr/data/button_builder.rb, line 37
def initialize
  @mode = :buttons
  @buttons = []
  @submenu = []
  val
end

Public Instance Methods

button(icon, path, options={}) click to toggle source
# File lib/tabulatr/data/button_builder.rb, line 48
def button(icon, path, options={})
  label = options.dup.delete(:label)
  if @mode == :buttons
    @buttons << {icon: icon, path: path, options: options}
  else
    @submenu << {icon: icon, label: label, path: path, options: options}
  end
  val
end
divider() click to toggle source
# File lib/tabulatr/data/button_builder.rb, line 66
def divider
  raise "use dividers only in submenu" unless @mode == :submenu
  @submenu << :divider
  val
end
submenu() { |self| ... } click to toggle source
val() click to toggle source
# File lib/tabulatr/data/button_builder.rb, line 44
def val
  {buttons: @buttons, submenu: @submenu}
end