Module: Rails::Generator::Commands
- Defined in:
- lib/rails_generator/commands.rb
Defined Under Namespace
Classes: Base, Create, Destroy, List, RewindBase, Update
Class Method Summary collapse
-
.append_features(base) ⇒ Object
Even more convenient access to commands.
-
.instance(command, generator) ⇒ Object
Here’s a convenient way to get a handle on generator commands.
Class Method Details
.append_features(base) ⇒ Object
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.
19 20 21 22 23 |
# File 'lib/rails_generator/commands.rb', line 19 def self.append_features(base) base.send(:define_method, :command) do |command| Commands.instance(command, self) end end |
.instance(command, generator) ⇒ Object
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.
12 13 14 |
# File 'lib/rails_generator/commands.rb', line 12 def self.instance(command, generator) const_get(command.to_s.camelize).new(generator) end |