From bb34863740d55a66db1d4266ddf294c30ede3c93 Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Mon, 13 Jun 2016 15:49:16 -0700 Subject: [RubygemsIntegration] Allow redefining private methods --- lib/bundler/rubygems_integration.rb | 10 ++++++++-- 1 file 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 -- cgit v1.2.1