diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2016-06-14 21:46:15 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-14 21:46:15 -0700 |
commit | e45c11f34b350ac74d661b03927e8345c2f7da4c (patch) | |
tree | 9f9960542794b1120f5fc5094223b48dcd6d23d4 | |
parent | 13f64fa210edbf92f3281e4055e88a37437d0486 (diff) | |
parent | bb34863740d55a66db1d4266ddf294c30ede3c93 (diff) | |
download | bundler-e45c11f34b350ac74d661b03927e8345c2f7da4c.tar.gz |
Merge pull request #4670 from bundler/seg-remove-private-methods
[RubygemsIntegration] Allow redefining private methods
-rw-r--r-- | lib/bundler/rubygems_integration.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index 41ebc87c..28259b72 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 |