diff options
author | Genadi Samokovarov <gsamokovarov@gmail.com> | 2016-02-04 10:40:04 +0100 |
---|---|---|
committer | Genadi Samokovarov <gsamokovarov@gmail.com> | 2016-02-04 10:40:17 +0100 |
commit | 5a4e878876a5813dca09fbf8b62180e3c1ba7aa6 (patch) | |
tree | 62608f2a0f6ee1d7f253776622cd6b0e23706463 | |
parent | a69281614a7ed6c134d9a799419dd34dd5293a81 (diff) | |
download | rails-5a4e878876a5813dca09fbf8b62180e3c1ba7aa6.tar.gz rails-5a4e878876a5813dca09fbf8b62180e3c1ba7aa6.tar.bz2 rails-5a4e878876a5813dca09fbf8b62180e3c1ba7aa6.zip |
Don't publicize Kernel core extensions
This is a reaction to a [bug] we hit in web-console. The cause of it was
a `Kernel` extension called `#console` that was public and was fighting
over Railties with console block to be run on `rails console`. We solved
it by making the method private. We did that through `module_function`
so `::Kernel.console` can be invoked even in `BasicObject`.
I'm proposing to make most of the core Active Support `Kernel`
extensions `module_function` as well. Those are currently public and we
are polluting every `Object` public interface with them.
```ruby
>> Object.new.respond_to? :silence_warnings
=> true
>> Object.new.respond_to? :with_warnings
=> true
>> Object.new.respond_to? :enable_warnings
=> true
>> Object.new.respond_to? :suppress
=> true
``
Some extensions like `Kernel#class_eval` should be public, but most of
them don't really need to be.
[bug]: https://github.com/rails/web-console/issues/184
-rw-r--r-- | activesupport/lib/active_support/core_ext/kernel/concern.rb | 2 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/kernel/reporting.rb | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/kernel/concern.rb b/activesupport/lib/active_support/core_ext/kernel/concern.rb index bf72caa058..18bcc01fa4 100644 --- a/activesupport/lib/active_support/core_ext/kernel/concern.rb +++ b/activesupport/lib/active_support/core_ext/kernel/concern.rb @@ -1,6 +1,8 @@ require 'active_support/core_ext/module/concerning' module Kernel + module_function + # A shortcut to define a toplevel concern, not within a module. # # See Module::Concerning for more. diff --git a/activesupport/lib/active_support/core_ext/kernel/reporting.rb b/activesupport/lib/active_support/core_ext/kernel/reporting.rb index 8afc258df8..d0197af95f 100644 --- a/activesupport/lib/active_support/core_ext/kernel/reporting.rb +++ b/activesupport/lib/active_support/core_ext/kernel/reporting.rb @@ -1,4 +1,6 @@ module Kernel + module_function + # Sets $VERBOSE to nil for the duration of the block and back to its original # value afterwards. # |