Class: Ramenu::RamenuDefiner

Inherits:
Object
  • Object
show all
Defined in:
lib/ramenu/ramenu_definer.rb

Overview

A menu definer to create menus in a block

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(menus, flags, options = {}) ⇒ RamenuDefiner

Returns a new instance of RamenuDefiner.



6
7
8
9
10
# File 'lib/ramenu/ramenu_definer.rb', line 6

def initialize(menus, flags, options = {})
  self.menus = menus
  self.flags = flags
  self.options = options
end

Instance Attribute Details

#flagsObject

Returns the value of attribute flags.



4
5
6
# File 'lib/ramenu/ramenu_definer.rb', line 4

def flags
  @flags
end

Returns the value of attribute menus.



4
5
6
# File 'lib/ramenu/ramenu_definer.rb', line 4

def menus
  @menus
end

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/ramenu/ramenu_definer.rb', line 4

def options
  @options
end

Instance Method Details

#add_menu(name, path = nil, options = {}, &block) ⇒ Object

create a new menu in a block



18
19
20
21
# File 'lib/ramenu/ramenu_definer.rb', line 18

def add_menu(name, path = nil, options = {}, &block)
  options[:flag_for_menu] = true if @options[:flag_for_menu] == true
  Ramenu.add_menu_to(menus, name, path, options, &block)
end

#set_flag(name, value = nil, options = {}) ⇒ Object

create a new flag in a block



13
14
15
# File 'lib/ramenu/ramenu_definer.rb', line 13

def set_flag(name, value = nil, options = {})
  Ramenu.set_flag_in(flags, name, value, options)
end