summaryrefslogtreecommitdiff
path: root/lib/bundler/rubygems_integration.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/bundler/rubygems_integration.rb')
-rw-r--r--lib/bundler/rubygems_integration.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index 41ebc87c77..28259b72ff 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -462,8 +462,14 @@ module Bundler
end
def redefine_method(klass, method, &block)
- if klass.instance_methods(false).include?(method)
- klass.send(:remove_method, method)
+ begin
+ if klass.instance_method(method) && method != :initialize
+ # doing this to ensure we also get private methods
+ klass.send(:remove_method, method)
+ end
+ rescue NameError
+ # method isn't defined
+ nil
end
klass.send(:define_method, method, &block)
end