1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Improve documentation of Rails::Command.find_by_namespace [skip ci]

* The documentation for `Rails::Command.find_by_namespace` shows an example
with 3 arguments but the method only accepts 2 arguments:
`namespace` and `command_name`.

* For both `namespace` and `namespace:command_name`, a namespace
with the `rails:` prepended is added.

* "rails:commands:webrat" isn't a namespace that can be returned as the
`Rails::Command::Base.namespace` removes the "commands:" part.
This commit is contained in:
Petrik 2021-02-13 11:32:56 +01:00
parent bddb2c9b19
commit fcce4994f9

View file

@ -60,14 +60,12 @@ module Rails
# Command names must end with "_command.rb". This is required because Rails # Command names must end with "_command.rb". This is required because Rails
# looks in load paths and loads the command just before it's going to be used. # looks in load paths and loads the command just before it's going to be used.
# #
# find_by_namespace :webrat, :rails, :integration # find_by_namespace :webrat, :integration
# #
# Will search for the following commands: # Will search for the following commands:
# #
# "rails:webrat", "webrat:integration", "webrat" # "webrat", "webrat:integration", "rails:webrat", "rails:webrat:integration"
# #
# Notice that "rails:commands:webrat" could be loaded as well, what
# Rails looks for is the first and last parts of the namespace.
def find_by_namespace(namespace, command_name = nil) # :nodoc: def find_by_namespace(namespace, command_name = nil) # :nodoc:
lookups = [ namespace ] lookups = [ namespace ]
lookups << "#{namespace}:#{command_name}" if command_name lookups << "#{namespace}:#{command_name}" if command_name