public
Description: resources_controller rails plugin: rc makes RESTful controllers fun
Homepage: http://plugins.ardes.com/doc/resources_controller
Clone URL: git://github.com/ianwhite/resources_controller.git
Click here to lend your support to: resources_controller and make a donation at www.pledgie.com !
Added include_actions extension for including actions/customising including 
actions. If you use your own Action modules, you can now define a module method 
#include_actions to do the :only / :except
  handling yourself.  See Ardes::ResourcesController::IncludeActions.  This 
  change is completely BC, you don't need
  to do anything to any of your existing action modules.
ianwhite (author)
Thu Oct 09 17:48:55 -0700 2008
commit  8a3691dce98e953bcf5186b024707f7f73f6c896
tree    7c525fec836605b06dffbef51837226cb30b83c7
parent  23f8b9e4d72e9e0b0837a972be596c36fbb65cca
...
 
 
 
 
1
2
3
...
1
2
3
4
5
6
7
0
@@ -1,3 +1,7 @@
0
+* If you use your own Action modules, you can now define a module method #include_actions to do the :only / :except 
0
+  handling yourself.  See Ardes::ResourcesController::IncludeActions.  This change is completely BC, you don't need 
0
+  to do anything to any of your existing action modules. 
0
+
0
 * use add_enclosing_resource to add your own enclosing resources if you're skipping load_enclosing_resources [Tom Stuart, Joel Chippindale]
0
 
0
 * The reason for the reversion in c21f35c has been fixed.  Thanks Jason Lee for the bug report.
...
484
485
486
487
488
489
490
491
492
 
 
 
493
494
495
496
497
498
499
500
501
502
503
504
505
 
 
506
507
508
...
484
485
486
 
 
 
 
 
 
487
488
489
490
 
 
 
 
 
 
 
 
 
 
 
 
491
492
493
494
495
0
@@ -484,25 +484,12 @@ module Ardes#:nodoc:
0
       map_enclosing_resource(*args, &block)
0
     end
0
     
0
-    # Include the specified module, optionally specifying which public methods to include
0
-    #
0
-    # eg
0
-    # 
0
-    #   include_actions ActionMixin, :only => :index
0
-    #   include_actions ActionMixin, :except => [:create, :new]
0
+    # Include the specified module, optionally specifying which public methods to include, for example:
0
+    #  include_actions ActionMixin, :only => :index
0
+    #  include_actions ActionMixin, :except => [:create, :new]
0
     def include_actions(mixin, options = {})
0
-      options.assert_valid_keys(:only, :except)
0
-      raise ArgumentError, "you can only specify either :except or :only, not both" if options[:only] && options[:except]
0
-      
0
-      mixin = mixin.dup
0
-      if only = options[:only]
0
-        only = Array(options[:only]).collect(&:to_s)
0
-        mixin.instance_methods.each {|m| mixin.send(:undef_method, m) unless only.include?(m)}
0
-      elsif except = options[:except]
0
-        except = Array(options[:except]).collect(&:to_s)
0
-        mixin.instance_methods.each {|m| mixin.send(:undef_method, m) if except.include?(m)}
0
-      end
0
-      include mixin
0
+      mixin.extend(IncludeActions) unless mixin.respond_to?(:include_actions)
0
+      mixin.include_actions(self, options)
0
     end
0
   
0
   private

Comments