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.
Methods
- C
- D
- E
- G
- I
- M
- N
- R
Instance Public methods
Does nothing for all commands except Create.
Replay action manifest. RewindBase subclass rewinds manifest.
Does nothing for all commands except Create.
Instance Protected methods
# File railties/lib/rails_generator/commands.rb, line 60 60: def current_migration_number 61: Dir.glob("#{RAILS_ROOT}/#{@migration_directory}/[0-9]*_*.rb").inject(0) do |max, file_path| 62: n = File.basename(file_path).split('_', 2).first.to_i 63: if n > max then n else max end 64: end 65: end
# File railties/lib/rails_generator/commands.rb, line 91 91: def gsub_file(relative_destination, regexp, *args, &block) 92: path = destination_path(relative_destination) 93: content = File.read(path).gsub(regexp, *args, &block) 94: File.open(path, 'wb') { |file| file.write(content) } 95: end