Module: Emenu

Defined in:
lib/emenu.rb,
lib/generators/emenu/install_generator.rb

Defined Under Namespace

Classes: InstallGenerator

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



27
28
29
30
31
# File 'lib/emenu.rb', line 27

def self.included(base)
  base.before_filter :emenu
  base.send :helper_method, :menu_will_render
  base.module_eval { include Navigation } unless $install == true
end

Instance Method Details

#emenuObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/emenu.rb', line 16

def emenu 
  session[:menu_state] ||= {}
  @menu = menu
  selected_key = @menu.find_path(request.env['PATH_INFO'])
  unless selected_key.nil?
    @menu.selected = selected_key 
    @menu.find(selected_key).parents.each { |menu| session[:menu_state][menu.title.to_s] = "opened" }
  end
  session[:menu_state].each { |key, value| @menu.open(key.to_sym) if value == "opened"} unless session[:menu_state].nil?
end

#emenu_stateObject



10
11
12
13
14
# File 'lib/emenu.rb', line 10

def emenu_state
  session[:menu_state] ||= {}
  session[:menu_state][params[:id]] = params[:state] unless params[:id].nil?
  render :json => { :data => :ok } 
end


33
34
35
# File 'lib/emenu.rb', line 33

def menu_will_render
  @menu.render
end