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
1 changed files with 2 additions and 4 deletions

View File

@ -60,14 +60,12 @@ module 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.
#
# find_by_namespace :webrat, :rails, :integration
# find_by_namespace :webrat, :integration
#
# 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:
lookups = [ namespace ]
lookups << "#{namespace}:#{command_name}" if command_name