dynamic_menu 3.0.0.rc1 → 3.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dynamic_menu/advanced_hash.rb +20 -0
- data/lib/dynamic_menu/base.rb +13 -1
- data/lib/dynamic_menu/version.rb +1 -1
- data/lib/dynamic_menu.rb +1 -0
- data/lib/engine.rb +2 -0
- data/lib/generators/dynamic_menu/menu_generator.rb +16 -0
- data/lib/generators/dynamic_menu/templates/menu.rb +7 -0
- data/test/dynamic_menu_test.rb +1 -0
- metadata +5 -2
@@ -0,0 +1,20 @@
|
|
1
|
+
module DynamicMenu
|
2
|
+
module AdvancedHash
|
3
|
+
class AdvancedHash
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@instance = Hash.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def tap! *args, &block
|
10
|
+
@instance = @instance.tap(*args, &block)
|
11
|
+
end
|
12
|
+
|
13
|
+
def method_missing method, *args, &block
|
14
|
+
super unless @instance.methods.index method
|
15
|
+
@instance.send method, *args, &block
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/dynamic_menu/base.rb
CHANGED
@@ -7,7 +7,7 @@ module DynamicMenu
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def get_menu_links
|
10
|
-
@menuLinks ||
|
10
|
+
@menuLinks || AdvancedHash::AdvancedHash.new
|
11
11
|
end
|
12
12
|
|
13
13
|
def method_missing(method, *args)
|
@@ -15,5 +15,17 @@ module DynamicMenu
|
|
15
15
|
@parent.send(method, *args)
|
16
16
|
end
|
17
17
|
|
18
|
+
def inherit_from menu_name
|
19
|
+
#@menuLinks ||= AdvancedHash::AdvancedHash.new
|
20
|
+
file = Rails.root.to_s+"/app/menus/#{params[:controller]}/#{menu_name}.rb"
|
21
|
+
load file
|
22
|
+
links_obj = "#{menu_name}Menu".classify.constantize.new(@parent)
|
23
|
+
@menuLinks = @menuLinks.merge(links_obj.get_menu_links)
|
24
|
+
end
|
25
|
+
|
26
|
+
def menu_instance
|
27
|
+
@menuLinks ||= AdvancedHash::AdvancedHash.new
|
28
|
+
end
|
29
|
+
|
18
30
|
end
|
19
31
|
end
|
data/lib/dynamic_menu/version.rb
CHANGED
data/lib/dynamic_menu.rb
CHANGED
data/lib/engine.rb
CHANGED
@@ -2,6 +2,8 @@ module DynamicMenu
|
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
initializer "dynamic_menu.inheritable_menus" do |app|
|
4
4
|
ActionView::Base.send :include, DynamicMenu::InheritableMenus
|
5
|
+
ActionView::Base.send :include, DynamicMenu::AdvancedHash
|
6
|
+
ActionController::Base.send :include, DynamicMenu::AdvancedHash
|
5
7
|
end
|
6
8
|
end
|
7
9
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module DynamicMenu
|
4
|
+
class MenuGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates',__FILE__)
|
6
|
+
def generate_menu
|
7
|
+
@args[0] =~ /(.+):.+/i
|
8
|
+
file = $1
|
9
|
+
dir = "app/menus/#{file}"
|
10
|
+
Dir.mkdir(dir) unless File.exists?(dir)
|
11
|
+
@args[0] =~ /.+:(.+)/i
|
12
|
+
@menu_name = $1
|
13
|
+
template "menu.rb", "app/menus/#{file}/#{@menu_name}.rb"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/test/dynamic_menu_test.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.0.
|
4
|
+
version: 3.0.0.rc2
|
5
5
|
prerelease: 6
|
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-07-
|
12
|
+
date: 2013-07-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -50,12 +50,15 @@ executables: []
|
|
50
50
|
extensions: []
|
51
51
|
extra_rdoc_files: []
|
52
52
|
files:
|
53
|
+
- lib/dynamic_menu/advanced_hash.rb
|
53
54
|
- lib/dynamic_menu/base.rb
|
54
55
|
- lib/dynamic_menu/inheritable_menus.rb
|
55
56
|
- lib/dynamic_menu/version.rb
|
56
57
|
- lib/dynamic_menu.rb
|
57
58
|
- lib/engine.rb
|
58
59
|
- lib/generators/dynamic_menu/install_generator.rb
|
60
|
+
- lib/generators/dynamic_menu/menu_generator.rb
|
61
|
+
- lib/generators/dynamic_menu/templates/menu.rb
|
59
62
|
- lib/tasks/dynamic_menu_tasks.rake
|
60
63
|
- MIT-LICENSE
|
61
64
|
- Rakefile
|