lib/zena/use.rb in zena-1.1.3 vs lib/zena/use.rb in zena-1.2.0
- old
+ new
@@ -1,15 +1,15 @@
module Zena
# This module is used to declare and manage the list of features used by Zena.
module Use
SUFFIX_NAME = 'Methods'
- MODULE_NAMES = %w{Controller View Zafu User Site Skin}
+ MODULE_NAMES = %w{Controller View Zafu User Site Skin Routes}
# "Controller" => "ControllerMethods"
MODULE_NAME = Hash[*MODULE_NAMES.map {|n| [n, "#{n}#{SUFFIX_NAME}"]}.flatten]
class << self
- attr_accessor :modules
+ attr_accessor :modules, :extra_routes
# Declare a module (or list of modules) that should be used in Zena. The module should implement
# sub-modules named ControllerMethods, ViewMethods or ZafuMethods in order to add features to
# the controller, view or zafu compiler respectively.
def module(*modules)
@@ -34,9 +34,20 @@
end
def modules_for(name)
create_module_hash
self.modules[name] || []
+ end
+
+ def routes(rez)
+ if self.extra_routes.nil?
+ hash = {}
+ each_module_for('Routes') do |mod|
+ hash.merge!(mod)
+ end
+ self.extra_routes = hash
+ end
+ (self.extra_routes[rez] || {})[rez] || {}
end
private
def create_module_hash
if self.modules.nil?