Module: Ramenu::ActionController::ClassMethods

Defined in:
lib/ramenu/action_controller.rb

Instance Method Summary collapse

Instance Method Details

#add_menu(name, path = nil, filter_options = {}, &block) ⇒ Object Also known as: add_menu_for_current

add a menu



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/ramenu/action_controller.rb', line 91

def add_menu(name, path = nil, filter_options = {}, &block)
  # This isn't really nice here
  if eval = Utils.convert_to_set_of_strings(filter_options.delete(:eval), %w(name path))
    name = Utils.instance_proc(name) if eval.include?("name")
    unless path.nil?
      path = Utils.instance_proc(path) if eval.include?("path")
    end
  end

  before_filter(filter_options) do |controller|
    # if path isn't defined, use current path
    path = request.fullpath if path.nil?

    controller.send(:add_menu, name, path, filter_options, &block)
  end
end

#definer(name = nil, filter_options = {}, &block) ⇒ Object

define volatile menus/flags in a block



110
111
112
113
114
# File 'lib/ramenu/action_controller.rb', line 110

def definer(name = nil, filter_options = {}, &block)
  before_filter(filter_options) do |controller|
    controller.send(:definer, name, filter_options, &block)
  end
end

#get_flag(name, filter_options = {}) ⇒ Object

get flag value



66
67
68
69
70
# File 'lib/ramenu/action_controller.rb', line 66

def get_flag(name, filter_options = {})
  before_filter(filter_options) do |controller|
    controller.send(:get_flag, name, filter_options)
  end
end

#reset_flag(name, filter_options = {}) ⇒ Object

reset flag value



80
81
82
83
84
# File 'lib/ramenu/action_controller.rb', line 80

def reset_flag(name, filter_options = {})
  before_filter(filter_options) do |controller|
    controller.send(:reset_flag, name, filter_options)
  end
end

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

set flag value



73
74
75
76
77
# File 'lib/ramenu/action_controller.rb', line 73

def set_flag(name, value, filter_options = {})
  before_filter(filter_options) do |controller|
    controller.send(:set_flag, name, value, filter_options)
  end
end