public
Description: A Ruby web application framework
Homepage: http://www.mackframework.com
Clone URL: git://github.com/markbates/mack.git
Click here to lend your support to: mack and make a donation at www.pledgie.com !
Feature: A Controller Registry is needed [#38 state:resolved]
markbates (author)
Fri Jul 18 14:25:15 -0700 2008
commit  f8b0b96ee82a3b3b82200faeaa4a7a0d2b6aae72
tree    829badcbafe078ddcf1f97289018d7f7047eef0f
parent  1cf308c8f1c572dba13fd83deb8a738744423565
...
364
365
366
 
367
368
369
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
370
371
372
...
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
0
@@ -364,8 +364,27 @@ module Mack
0
     # Make sure that all the class level methods got included into the receiver's class
0
     #
0
     def self.included(base)
0
+      Mack::Controller::Registry.instance.controllers << base
0
       base.extend(ClassMethods)
0
     end
0
     
0
+    # Houses a repository of all the controllers in the system.
0
+    class Registry
0
+      include Singleton
0
+      
0
+      attr_reader :controllers
0
+      
0
+      def initialize
0
+        @controllers = []
0
+      end
0
+      
0
+      # Add a controller to the registry.
0
+      def self.add(controller)
0
+        Mack::Controller::Registry.instance.controllers << controller
0
+        Mack::Controller::Registry.instance.controllers.uniq!
0
+      end
0
+      
0
+    end
0
+    
0
   end # Controller
0
 end # Mack
0
\ No newline at end of file
...
30
31
32
 
 
 
 
 
 
 
 
 
 
 
 
33
34
35
...
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
0
@@ -30,6 +30,18 @@ end
0
 
0
 describe Mack::Controller do
0
   
0
+  describe Mack::Controller::Registry do
0
+    
0
+    it "should hold a list of all the controllers registered with Mack" do
0
+      class RegTestController
0
+      end
0
+      Mack::Controller::Registry.instance.controllers.should_not include(RegTestController)
0
+      RegTestController.send(:include, Mack::Controller)
0
+      Mack::Controller::Registry.instance.controllers.should include(RegTestController)
0
+    end
0
+    
0
+  end
0
+  
0
   before(:all) do
0
     Mack::Routes.build do |r|
0
       r.you_want_what "/yww", :controller => "wants_test", :action => :you_want_what

Comments