Skip to content

Commit

Permalink
Use clone to copy class methods in 1.8.7
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tpope committed Nov 20, 2008
1 parent 8457e57 commit 60b5f27
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/ardes/resources_controller/include_actions.rb
Expand Up @@ -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
Expand All @@ -36,4 +36,4 @@ def action_methods_to_remove(options = {})
end
end
end
end
end

0 comments on commit 60b5f27

Please sign in to comment.