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