From 60b5f270ba2c22fd24e2a93c8f4468416da75374 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Wed, 19 Nov 2008 20:32:44 -0500 Subject: [PATCH] Use clone to copy class methods in 1.8.7 In Ruby 1.8.7 (but not 1.8.6 or 1.9), Object#dup does not copy an object's singleton methods. CUrrently, resources_controller exposes this difference with a duped module that lacks the included callback of its original. This can be worked around by simply invoking #clone instead, which does not suffer from this problem. --- lib/ardes/resources_controller/include_actions.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ardes/resources_controller/include_actions.rb b/lib/ardes/resources_controller/include_actions.rb index 8444351..9780961 100644 --- a/lib/ardes/resources_controller/include_actions.rb +++ b/lib/ardes/resources_controller/include_actions.rb @@ -16,7 +16,7 @@ module IncludeActions def include_actions(controller, options = {}) options.assert_valid_keys(:only, :except) raise ArgumentError, "you can only specify either :except or :only, not both" if options[:only] && options[:except] - mixin = self.dup + mixin = self.clone action_methods_to_remove(options).each {|a| mixin.remove_action_method(a) } controller.send :include, mixin end @@ -36,4 +36,4 @@ def action_methods_to_remove(options = {}) end end end -end \ No newline at end of file +end