Class: Alacarte::Menus

Inherits:
Hash
  • Object
show all
Defined in:
lib/alacarte/menus.rb

Overview

Alacarte::Menus provides a dsl for building menus.

Instance Method Summary collapse

Instance Method Details

#draw(&block) ⇒ Object

Draw the menu



6
7
8
# File 'lib/alacarte/menus.rb', line 6

def draw(&block)
  self.instance_exec(&block)
end

Define a menu in a draw block



11
12
13
14
15
16
17
# File 'lib/alacarte/menus.rb', line 11

def menu(name, *args, &block)
  if self[name]
    self[name].extend(&block)
  else
    self[name] = Menu.new(nil, :menu, name, *args, &block)
  end
end