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 IncludeActions#methods_to_remove which enables easier custom behaviour for 
action modules
ianwhite (author)
Thu Oct 09 19:07:17 -0700 2008
commit  aa2c6e2d266bfa800fd00215a6a9cb125c76449d
tree    8a8b98b25c39d0bd679d3b4cd561defbfe3b76f8
parent  8a3691dce98e953bcf5186b024707f7f73f6c896
...
16
17
18
19
20
21
22
23
24
25
26
27
 
28
29
 
 
 
 
 
 
 
 
 
 
30
31
32
33
...
16
17
18
 
19
 
 
 
 
 
 
 
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
0
@@ -16,17 +16,20 @@ module Ardes
0
       def include_actions(controller, 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 = self.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
+        methods_to_remove(options).each {|m| mixin.send(:undef_method, m)}
0
         controller.send :include, mixin
0
       end
0
+      
0
+      def methods_to_remove(options = {})
0
+        if options[:only]
0
+          instance_methods - options[:only].map(&:to_s)
0
+        elsif options[:except]
0
+          options[:except].map(&:to_s) & instance_methods
0
+        else
0
+          []
0
+        end
0
+      end
0
     end
0
   end
0
 end
0
\ No newline at end of file

Comments