diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2016-09-14 19:16:15 +0200 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2016-09-16 12:20:39 +0200 |
commit | 0b51b647d30228d4cbf86f5c6d5ff2c3171696e7 (patch) | |
tree | 4254b79f0af9ed23f21cd870c815f754564c7538 | |
parent | 4d885bca65f9b1324a68e3f5c0c56575076a204c (diff) | |
download | bundler-0b51b647d30228d4cbf86f5c6d5ff2c3171696e7.tar.gz |
[RubygemsIntegration] Ensure redefined methods have the same visibility
-rw-r--r-- | lib/bundler/rubygems_integration.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index c1bb6c7ab8..23648554b7 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 @@ -504,6 +505,17 @@ module Bundler elsif block klass.send(:define_method, method, &block) end + klass.send(visibility, method) + end + + def method_visibility(klass, method) + if klass.private_method_defined?(method) + :private + elsif klass.protected_method_defined?(method) + :protected + else + :public + end end # Rubygems 1.4 through 1.6 |