Module: Ramenu

Defined in:
lib/ramenu.rb,
lib/ramenu/menus.rb,
lib/ramenu/config.rb,
lib/ramenu/railtie.rb,
lib/ramenu/version.rb,
lib/ramenu/ramenu_definer.rb,
lib/ramenu/ramenu_methods.rb,
lib/ramenu/action_controller.rb

Defined Under Namespace

Modules: ActionController, Menus, Version Classes: Configuration, Railtie, RamenuDefiner

Constant Summary collapse

DEFAULT_GROUP =
:default
VERSION =
Version::STRING

Class Method Summary collapse

Class Method Details

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

menus



36
37
38
39
# File 'lib/ramenu/ramenu_methods.rb', line 36

def self.add_menu(name, path, options = {}, &block)
  menu = options[:menu]
  add_menu_to(static_menus(menu), name, path, options, &block)
end

.add_menu_to(menu, name, path, options = {}, &block) ⇒ Object

add a new menu element to a set of menus



22
23
24
# File 'lib/ramenu/ramenu_methods.rb', line 22

def self.add_menu_to(menu, name, path, options = {}, &block)
  menu << new_ramenu_element(name, path, options, &block)
end

.configObject

Global settings for Ramenu



10
11
12
# File 'lib/ramenu/config.rb', line 10

def self.config
  @config
end

.configure {|@config ||= Ramenu::Configuration.new| ... } ⇒ Object

Configures global settings for Ramenu

Yields:



5
6
7
# File 'lib/ramenu/config.rb', line 5

def self.configure(&block)
  yield @config ||= Ramenu::Configuration.new
end

.new_ramenu_element(name, path = nil, options = {}) {|elem| ... } ⇒ Object

create a new menu element

Yields:

  • (elem)


27
28
29
30
31
32
33
# File 'lib/ramenu/ramenu_methods.rb', line 27

def self.new_ramenu_element(name, path = nil, options = {}, &block)
  options[:flag] = name if options[:flag_for_menu] == true && name.is_a?(Symbol)
  
  elem = Menus::Element.new(name, path, options)
  yield elem if block_given?
  return elem
end

.set_flag_in(flags, name, value, options = {}) ⇒ Object

add a new flag to a set of flags



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

def self.set_flag_in(flags, name, value, options = {})
  flags.merge!({ name => value }) unless name.nil? || value.nil?
end

.static_flags(flagset = nil) ⇒ Object

flags



4
5
6
7
8
# File 'lib/ramenu/ramenu_methods.rb', line 4

def self.static_flags(flagset = nil)
  flagset = DEFAULT_GROUP if flagset.nil?
  @ramenu_flags ||= {}
  @ramenu_flags[flagset] ||= {}
end

.static_menus(menu = nil) ⇒ Object

return static menus



11
12
13
14
15
# File 'lib/ramenu/ramenu_methods.rb', line 11

def self.static_menus(menu = nil)
  menu = DEFAULT_GROUP if menu.nil? 
  @ramenu_menus ||= {}
  @ramenu_menus[menu] ||= []
end