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

Attributes included from Options

#options

Instance Method Summary collapse

Methods inherited from Base

#destination_path, #initialize, #manifest, #source_path

Methods included from Options

included

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.



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

def class_collisions(*class_names)
end

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



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

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.



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

def invoke!
  manifest.replay(self)
end

#readme(*args) ⇒ Object

Does nothing for all commands except Create.



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

def readme(*args)
end