diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2019-07-16 15:38:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-16 15:38:11 +0100 |
commit | da4e18c5c2e965bfdfc442b92881326453de6f80 (patch) | |
tree | 3a7b75286e601892b4d244e48e9a3325585e4422 /activesupport/lib | |
parent | fdd5894aa985651fb99e0ef1c2d3f3f604b2f659 (diff) | |
parent | 223a187b9e73d9ad568d7333c4a1d0f84362d547 (diff) | |
download | rails-da4e18c5c2e965bfdfc442b92881326453de6f80.tar.gz rails-da4e18c5c2e965bfdfc442b92881326453de6f80.tar.bz2 rails-da4e18c5c2e965bfdfc442b92881326453de6f80.zip |
Merge pull request #36685 from Shopify/as-depedencies-unhook-fix
Fix Loadable.exclude_from to also reset Kernel#require
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/dependencies.rb | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 5dc47b20c6..32cb3a53f4 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -201,6 +201,11 @@ module ActiveSupport #:nodoc: end end + def self.include_into(base) + base.include(self) + append_features(base) + end + def const_missing(const_name) from_mod = anonymous? ? guess_for_anonymous(const_name) : self Dependencies.load_missing_constant(from_mod, const_name) @@ -230,6 +235,21 @@ module ActiveSupport #:nodoc: base.class_eval do define_method(:load, Kernel.instance_method(:load)) private :load + + define_method(:require, Kernel.instance_method(:require)) + private :require + end + end + + def self.include_into(base) + base.include(self) + + if base.instance_method(:load).owner == base + base.remove_method(:load) + end + + if base.instance_method(:require).owner == base + base.remove_method(:require) end end @@ -325,9 +345,9 @@ module ActiveSupport #:nodoc: end def hook! - Object.class_eval { include Loadable } - Module.class_eval { include ModuleConstMissing } - Exception.class_eval { include Blamable } + Loadable.include_into(Object) + ModuleConstMissing.include_into(Module) + Exception.include(Blamable) end def unhook! |