Sha256: e7e61478ea695a022a6e2d04d8b41c6edc2b77196a1cf86d4b6c8ef562f64d29

Contents?: true

Size: 1.03 KB

Versions: 21

Compression:

Stored size: 1.03 KB

Contents

module Alchemy
	module Modules

		@@alchemy_modules = YAML.load_file(File.join(File.dirname(__FILE__), '../..', 'config/alchemy', 'modules.yml'))

		def self.included(base)
			base.send :helper_method, :alchemy_modules, :module_definition_for
		end

		def alchemy_modules
			@@alchemy_modules
		end

		def module_definition_for(name)
			if name.is_a? String
				alchemy_modules.detect{ |p| p["name"] == name }
			elsif name.is_a? Hash
				alchemy_modules.detect do |alchemy_module|
					alchemy_module.stringify_keys!
					name.symbolize_keys!
					module_navi = alchemy_module["navigation"].stringify_keys
					if module_navi["sub_navigation"]
						module_navi["sub_navigation"].map(&:stringify_keys).detect do |subnavi|
							subnavi["controller"].gsub(/^\//, '') == name[:controller] && subnavi["action"] == name[:action]
						end
					end
				end
			else
				raise "Could not find module definition for #{name}"
			end
		end

		def self.register_module(module_definition)
			@@alchemy_modules << module_definition.stringify_keys
		end

	end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
alchemy_cms-2.1.12 lib/alchemy/modules.rb
alchemy_cms-2.1.11 lib/alchemy/modules.rb
alchemy_cms-2.1.9.1 lib/alchemy/modules.rb
alchemy_cms-2.1.9 lib/alchemy/modules.rb
alchemy_cms-2.1.8.1 lib/alchemy/modules.rb
alchemy_cms-2.1.8 lib/alchemy/modules.rb
alchemy_cms-2.1.7 lib/alchemy/modules.rb
alchemy_cms-2.1.6 lib/alchemy/modules.rb
alchemy_cms-2.1.5 lib/alchemy/modules.rb
alchemy_cms-2.1.4 lib/alchemy/modules.rb
alchemy_cms-2.1.3 lib/alchemy/modules.rb
alchemy_cms-2.1.2 lib/alchemy/modules.rb
alchemy_cms-2.1.1 lib/alchemy/modules.rb
alchemy_cms-2.1 lib/alchemy/modules.rb
alchemy_cms-2.1.rc6 lib/alchemy/modules.rb
alchemy_cms-2.1.rc5 lib/alchemy/modules.rb
alchemy_cms-2.1.rc4 lib/alchemy/modules.rb
alchemy_cms-2.1.rc3 lib/alchemy/modules.rb
alchemy_cms-2.1.rc2 lib/alchemy/modules.rb
alchemy_cms-2.1.beta6 lib/alchemy/modules.rb