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

append_features

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.



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

def class_collisions(*class_names)
end

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



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

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.



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

def invoke!
  manifest.replay(self)
end

#readme(*args) ⇒ Object

Does nothing for all commands except Create.



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

def readme(*args)
end