Method: Rails::Command.find_by_namespace
- Defined in:
- railties/lib/rails/command.rb
.find_by_namespace(namespace, command_name = nil) ⇒ Object
Rails finds namespaces similar to Thor, it only adds one rule:
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, :integration
Will search for the following commands:
"webrat", "webrat:integration", "rails:webrat", "rails:webrat:integration"
90 91 92 93 94 95 96 97 98 99 |
# File 'railties/lib/rails/command.rb', line 90 def find_by_namespace(namespace, command_name = nil) # :nodoc: lookups = [ namespace ] lookups << "#{namespace}:#{command_name}" if command_name lookups.concat lookups.map { |lookup| "rails:#{lookup}" } lookup(lookups) namespaces = subclasses.index_by(&:namespace) namespaces[(lookups & namespaces.keys).first] end |