Class: Rails::Generators::Db::System::ChangeGenerator
- Includes:
- AppName, Rails::Generators::Database
- Defined in:
- railties/lib/rails/generators/rails/db/system/change/change_generator.rb
Overview
:nodoc:
Constant Summary
Constants included from AppName
Constants included from Rails::Generators::Database
Rails::Generators::Database::DATABASES, Rails::Generators::Database::JDBC_DATABASES
Class Method Summary collapse
Instance Method Summary collapse
- #edit_database_config ⇒ Object
- #edit_gemfile ⇒ Object
-
#initialize ⇒ ChangeGenerator
constructor
A new instance of ChangeGenerator.
Methods included from Rails::Generators::Database
#convert_database_option_for_jruby, #gem_for_database
Methods inherited from Base
base_root, class_option, default_source_root, desc, exit_on_failure?, hide!, hook_for, inherited, namespace, remove_hook_for, source_root
Methods included from Actions
#add_source, #environment, #gem, #gem_group, #generate, #git, #github, #initializer, #lib, #rails_command, #rake, #rakefile, #readme, #route, #vendor
Constructor Details
#initialize ⇒ ChangeGenerator
Returns a new instance of ChangeGenerator.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'railties/lib/rails/generators/rails/db/system/change/change_generator.rb', line 21 def initialize(*) super unless DATABASES.include?([:to]) raise Error, "Invalid value for --to option. Supported preconfigurations are: #{DATABASES.join(", ")}." end opt = .dup opt[:database] ||= opt[:to] self. = opt.freeze end |
Class Method Details
Instance Method Details
#edit_database_config ⇒ Object
33 34 35 |
# File 'railties/lib/rails/generators/rails/db/system/change/change_generator.rb', line 33 def edit_database_config template("config/databases/#{[:database]}.yml", "config/database.yml") end |
#edit_gemfile ⇒ Object
37 38 39 40 41 |
# File 'railties/lib/rails/generators/rails/db/system/change/change_generator.rb', line 37 def edit_gemfile name, version = gem_for_database gsub_file("Gemfile", all_database_gems_regex, name) gsub_file("Gemfile", gem_entry_regex_for(name), gem_entry_for(name, *version)) end |