lib/nitro/dispatcher.rb in nitro-0.9.3 vs lib/nitro/dispatcher.rb in nitro-0.9.5
- old
+ new
@@ -1,10 +1,8 @@
-#--
-# George Moschovitis <gm@navel.gr>
+# * George Moschovitis <gm@navel.gr>
# (c) 2004-2005 Navel, all rights reserved.
# $Id$
-#++
module N
require 'nitro/controller'
@@ -22,17 +20,36 @@
# APIs map.
attr_accessor :apis
+ # Create a new Dispatcher.
+ #
+ # Input:
+ #
+ # [+controllers+]
+ # Either a hash of controller mappings or a single
+ # controller that gets mapped to :index.
+ #
+ # [+apis+]
+ # A hash of apis supported by the Dispatcher.
+
def initialize(controllers = nil, apis = nil)
@root = 'root'
- @controllers = controllers || { :index => Controller }
+
+ if controllers and controllers.is_a?(Class) and controllers.ancestors.include?(Controller)
+ @controllers = { :index => controllers }
+ else
+ @controllers = controllers || { :index => Controller }
+ end
+
@apis = apis
end
# Process the given hash and mount the
# defined controllers.
+ #
+ # Input:
#
# [+controllers+]
# A hash representing the mapping of
# mount points to controllers.
#