Class: Rails::Generator::Commands::Base

Inherits:
Base show all
Defined in:
lib/rails_generator/commands.rb

Overview

Generator commands delegate Rails::Generator::Base and implement a standard set of actions. Their behavior is defined by the way they respond to these actions: Create brings life; Destroy brings death; List passively observes.

Commands are invoked by replaying (or rewinding) the generator’s manifest of actions. See Rails::Generator::Manifest and Rails::Generator::Base#manifest method that generator subclasses are required to override.

Commands allows generators to “plug in” invocation behavior, which corresponds to the GoF Strategy pattern.

Direct Known Subclasses

Create, List, RewindBase

Instance Attribute Summary

Attributes inherited from Base

#args, #destination_root, #source_root

Instance Method Summary collapse

Methods inherited from Base

#destination_path, #initialize, #manifest, #source_path

Constructor Details

This class inherits a constructor from Rails::Generator::Base

Instance Method Details

#class_collisions(*class_names) ⇒ Object

Does nothing for all commands except Create.



52
53
# File 'lib/rails_generator/commands.rb', line 52

def class_collisions(*class_names)
end

#dependency(generator_name, args, runtime_options = {}) ⇒ Object



45
46
47
48
49
# File 'lib/rails_generator/commands.rb', line 45

def dependency(generator_name, args, runtime_options = {})
  logger.dependency(generator_name) do
    self.class.new(instance(generator_name, args, full_options(runtime_options))).invoke!
  end
end

#invoke!Object

Replay action manifest. RewindBase subclass rewinds manifest.



41
42
43
# File 'lib/rails_generator/commands.rb', line 41

def invoke!
  manifest.replay(self)
end

#readme(*args) ⇒ Object

Does nothing for all commands except Create.



56
57
# File 'lib/rails_generator/commands.rb', line 56

def readme(*args)
end