diff options
-rw-r--r-- | lib/bundler/rubygems_integration.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index c1bb6c7ab8..23ae95aa04 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -489,6 +489,7 @@ module Bundler end def redefine_method(klass, method, unbound_method = nil, &block) + visibility = method_visibility(klass, method) begin if (instance_method = klass.instance_method(method)) && method != :initialize # doing this to ensure we also get private methods @@ -501,8 +502,20 @@ module Bundler @replaced_methods[[method, klass]] = instance_method if unbound_method klass.send(:define_method, method, unbound_method) + klass.send(visibility, method) elsif block klass.send(:define_method, method, &block) + klass.send(visibility, method) + end + end + + def method_visibility(klass, method) + if klass.private_method_defined?(method) + :private + elsif klass.protected_method_defined?(method) + :protected + else + :public end end |