dynamic_menu 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
data/lib/dynamic_menu/base.rb
CHANGED
@@ -21,7 +21,7 @@ module DynamicMenu
|
|
21
21
|
#@menuLinks ||= AdvancedHash::AdvancedHash.new
|
22
22
|
file = Rails.root.to_s+"/app/menus/#{params[:controller]}/#{menu_name}.rb"
|
23
23
|
load file
|
24
|
-
links_obj = "#{menu_name}
|
24
|
+
links_obj = "#{menu_name}_menu".camelize.classify.constantize.new(@parent)
|
25
25
|
@menuLinks.concat(links_obj.get_menu_links)
|
26
26
|
end
|
27
27
|
|
@@ -5,28 +5,23 @@ module DynamicMenu
|
|
5
5
|
def get_current_menu
|
6
6
|
path = Rails.root.join('app/menus')
|
7
7
|
full_path = path + "#{params[:controller]}/#{params[:action]}.rb"
|
8
|
+
second_chance = path + "#{params[:controller]}/#{try_again? params[:action]}.rb"
|
9
|
+
logger.debug("Dynamic Menu:\n\r\tFirst Chance: #{params[:action]}\n\r\tSecond Chance: #{try_again? params[:action]}")
|
8
10
|
if File.exists?(full_path)
|
9
11
|
load full_path
|
10
|
-
"#{params[:action]}
|
11
|
-
|
12
|
-
#Depending on the action (for example edit) it should look for a relationship (:create=:new or :update=:edit
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
def dynamic_menu_file_loader controller, action
|
17
|
-
path = Rails.root.join('app/menus')
|
18
|
-
full_path += "#{controller}/#{action}.rb"
|
19
|
-
try_again_des = try_again? action
|
20
|
-
if !try_again_des.nil?
|
21
|
-
dynamic_menu_file_loader controller, try_again_des
|
12
|
+
"#{params[:action]}_menu".classify.constantize.new(self)
|
13
|
+
elsif File.exists?(second_chance)
|
14
|
+
#Depending on the action (for example edit) it should look for a relationship (:create=:new or :update=:edit
|
15
|
+
load second_chance
|
16
|
+
"#{try_again? params[:action]}_menu".classify.constantize.new(self)
|
22
17
|
end
|
23
18
|
end
|
24
19
|
|
25
20
|
def try_again? action
|
26
|
-
if action ==
|
27
|
-
return
|
28
|
-
elsif action ==
|
29
|
-
return
|
21
|
+
if action == "create"
|
22
|
+
return "new"
|
23
|
+
elsif action == "update"
|
24
|
+
return "edit"
|
30
25
|
end
|
31
26
|
end
|
32
27
|
|
data/lib/dynamic_menu/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamic_menu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -215,3 +215,4 @@ test_files:
|
|
215
215
|
- test/dummy/tmp/cache/assets/development/sprockets/fb73ad3c1bb98bc69153c7f8a81f41aa
|
216
216
|
- test/dynamic_menu_test.rb
|
217
217
|
- test/test_helper.rb
|
218
|
+
has_rdoc:
|