Class: DynamicMenu::Base
- Inherits:
-
Object
show all
- Defined in:
- lib/dynamic_menu/base.rb
Instance Method Summary
collapse
Constructor Details
#initialize(parent) ⇒ Base
Returns a new instance of Base.
4
5
6
7
8
9
|
# File 'lib/dynamic_menu/base.rb', line 4
def initialize(parent)
@parent ||= parent
load_instance_vars
@menuLinks = AdvancedArray.new
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
15
16
17
18
|
# File 'lib/dynamic_menu/base.rb', line 15
def method_missing(method, *args)
super unless @parent.methods.index method
@parent.send(method, *args)
end
|
Instance Method Details
#add(*args) ⇒ Object
38
39
40
41
42
|
# File 'lib/dynamic_menu/base.rb', line 38
def add *args
args.each do |arg|
@menuLinks << arg
end
end
|
11
12
13
|
# File 'lib/dynamic_menu/base.rb', line 11
def
@menuLinks || AdvancedArray.new
end
|
#inherit_from(menu_name) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/dynamic_menu/base.rb', line 20
def inherit_from
file = Rails.root.to_s+"/app/menus/#{params[:controller]}/#{}.rb"
load file
links_obj = "#{}_menu".camelize.classify.constantize.new(@parent)
@menuLinks.concat(links_obj.)
end
|
#load_instance_vars ⇒ Object
28
29
30
31
32
|
# File 'lib/dynamic_menu/base.rb', line 28
def load_instance_vars
@parent.instance_variables.each do |var|
instance_variable_set(var.intern,@parent.instance_variable_get(var.intern))
end
end
|
34
35
36
|
# File 'lib/dynamic_menu/base.rb', line 34
def
@menuLinks ||= AdvancedArray.new
end
|