-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Continue including Rails::ConsoleMethods to IRB's internal
Due to some users/libs relying on Rails::ConsoleMethod to extend Rails console, we need to keep including it to IRB's internal. But to prevent also adding `app` and `helper` methods to the console, which are already registered to IRB through its API, we need to remove them from the Rails::ConsoleMethods. Additionally, we should raise deprecation warning when users try to use Rails::ConsoleMethods in this way. This commit: - Removes all methods from Rails::ConsoleMethods that are already registered to IRB. So it's now essentially empty. - Raises a deprecation warning when modules are included to Rails::ConsoleMethods or methods are added to it. - Adds a test to ensure that the deprecation warning is raised and the methods are available in the console.
- Loading branch information
Showing
7 changed files
with
81 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
module Rails | ||
module ConsoleMethods | ||
def self.include(_mod, ...) | ||
raise_deprecation_warning | ||
super | ||
end | ||
|
||
def self.method_added(_method_name) | ||
raise_deprecation_warning | ||
super | ||
end | ||
|
||
def self.raise_deprecation_warning | ||
ActiveSupport::Deprecation.new.warn(<<~MSG, caller_locations(1..1)) | ||
Extending Rails console through `Rails::ConsoleMethods` is deprecated and will be removed in Rails 7.3. | ||
Please directly use IRB's extension API to add new commands or helpers to the console. | ||
For more details, please visit: https://github.com/ruby/irb/blob/master/EXTEND_IRB.md | ||
MSG | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters