dynamic_menu 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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}Menu".classify.constantize.new(@parent)
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]}Menu".classify.constantize.new(self)
11
- else
12
- #Depending on the action (for example edit) it should look for a relationship (:create=:new or :update=:edit)
13
- end
14
- end
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 == :create
27
- return :new
28
- elsif action == :update
29
- return :edit
21
+ if action == "create"
22
+ return "new"
23
+ elsif action == "update"
24
+ return "edit"
30
25
  end
31
26
  end
32
27
 
@@ -1,3 +1,3 @@
1
1
  module DynamicMenu
2
- VERSION = "3.0.1"
2
+ VERSION = "3.0.2"
3
3
  end
@@ -1,4 +1,4 @@
1
- class <%= @menu_name.capitalize %>Menu < DynamicMenu::Base
1
+ class <%= "#{@menu_name}_menu".classify %>< DynamicMenu::Base
2
2
  def build_menu
3
3
  add link_to "Change me","#" if can? :read, All #change this line and add lines using add
4
4
  end
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.1
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-06 00:00:00.000000000 Z
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: