| Module | Rails::Generator::Commands |
| In: |
vendor/rails/railties/lib/rails_generator/commands.rb
|
Even more convenient access to commands. Include Commands in the generator Base class to get a nice command instance method which returns a delegate for the requested command.
# File vendor/rails/railties/lib/rails_generator/commands.rb, line 20
20: def self.included(base)
21: base.send(:define_method, :command) do |command|
22: Commands.instance(command, self)
23: end
24: end
Here‘s a convenient way to get a handle on generator commands. Command.instance(‘destroy’, my_generator) instantiates a Destroy delegate of my_generator ready to do your dirty work.
# File vendor/rails/railties/lib/rails_generator/commands.rb, line 13
13: def self.instance(command, generator)
14: const_get(command.to_s.camelize).new(generator)
15: end