From a69281614a7ed6c134d9a799419dd34dd5293a81 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Thu, 28 Jan 2016 18:22:01 +0900 Subject: :arrow_left: indentation [ci-skip] --- activesupport/lib/active_support/core_ext/module/deprecation.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activesupport/lib/active_support/core_ext') diff --git a/activesupport/lib/active_support/core_ext/module/deprecation.rb b/activesupport/lib/active_support/core_ext/module/deprecation.rb index 56d670fbe8..f3f2e7f5fc 100644 --- a/activesupport/lib/active_support/core_ext/module/deprecation.rb +++ b/activesupport/lib/active_support/core_ext/module/deprecation.rb @@ -13,8 +13,8 @@ class Module # # class MyLib::Deprecator # def deprecation_warning(deprecated_method_name, message, caller_backtrace = nil) - # message = "#{deprecated_method_name} is deprecated and will be removed from MyLibrary | #{message}" - # Kernel.warn message + # message = "#{deprecated_method_name} is deprecated and will be removed from MyLibrary | #{message}" + # Kernel.warn message # end # end def deprecate(*method_names) -- cgit v1.2.3 From 5a4e878876a5813dca09fbf8b62180e3c1ba7aa6 Mon Sep 17 00:00:00 2001 From: Genadi Samokovarov Date: Thu, 4 Feb 2016 10:40:04 +0100 Subject: 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 --- activesupport/lib/active_support/core_ext/kernel/concern.rb | 2 ++ activesupport/lib/active_support/core_ext/kernel/reporting.rb | 2 ++ 2 files changed, 4 insertions(+) (limited to 'activesupport/lib/active_support/core_ext') 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. # -- cgit v1.2.3 From 783858c8e150eb0f98d7e5d893e492ee08998662 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 8 Feb 2016 15:48:59 -0800 Subject: drop array allocations on `html_safe` For better or worse, anonymous `*` args will allocate arrays. Ideally, the interpreter would optimize away this allocation. However, given the number of times we call `html_safe` it seems worth the shedding idealism and going for performance. This line was the top allocation spot for a scaffold (and presumably worse on real applications). --- activesupport/lib/active_support/core_ext/string/output_safety.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib/active_support/core_ext') diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb index 6251f34daf..43b9fd4bf7 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -171,7 +171,7 @@ module ActiveSupport #:nodoc: original_concat(value) end - def initialize(*) + def initialize(str = '') @html_safe = true super end -- cgit v1.2.3