Class: Cms::ModuleInstallation
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Cms::ModuleInstallation
- Defined in:
- lib/cms/module_installation.rb
Overview
Provides a base class for Module installation generators.
This strategy assumes that modules will subclass this, and copy files from their db/migrate directory. Usage:
require 'cms/module_installation'
class MyModule::InstallGenerator < Cms::ModuleInstallation
add_migrations_directory_to_source_root __FILE__
copy_migration_file 'DATE_STAMP_create_some_block_name.rb'
end
Class Method Summary collapse
-
.add_migrations_directory_to_source_root(generator_file_object) ⇒ Object
This will be relative to the gem e.g.
-
.copy_migration_file(name_of_file) ⇒ Object
Add a migration file to the list of files to be copied from this gem into the project.
- .migration_files ⇒ Object
Instance Method Summary collapse
Class Method Details
.add_migrations_directory_to_source_root(generator_file_object) ⇒ Object
This will be relative to the gem e.g. add_migrations_directory_to_source_root __FILE__
16 17 18 |
# File 'lib/cms/module_installation.rb', line 16 def self.add_migrations_directory_to_source_root(generator_file_object) source_root File.('../../../../../db/migrate/', generator_file_object) end |
.copy_migration_file(name_of_file) ⇒ Object
Add a migration file to the list of files to be copied from this gem into the project.
21 22 23 24 |
# File 'lib/cms/module_installation.rb', line 21 def self.copy_migration_file(name_of_file) @migration_files = [] unless @migration_files @migration_files << name_of_file end |
.migration_files ⇒ Object
26 27 28 |
# File 'lib/cms/module_installation.rb', line 26 def self.migration_files @migration_files end |
Instance Method Details
#copy_migrations_to_project ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/cms/module_installation.rb', line 30 def copy_migrations_to_project if self.class.migration_files self.class.migration_files.each do |file_name| copy_file file_name, "db/migrate/#{file_name}" end end end |