Class: SettingsDB::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- SettingsDB::Generators::InstallGenerator
- Extended by:
- ActiveRecord::Generators::Migration
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/settingsdb/install_generator.rb
Instance Method Summary collapse
- #add_settingsdb_initializer ⇒ Object
- #add_settingsdb_migration ⇒ Object
- #add_settingsdb_model ⇒ Object
- #inject_settingsdb_content ⇒ Object
Instance Method Details
#add_settingsdb_initializer ⇒ Object
41 42 43 44 |
# File 'lib/generators/settingsdb/install_generator.rb', line 41 def add_settingsdb_initializer return if initializer_exists? template 'initializer.rb', 'config/initializers/settingsdb.rb' end |
#add_settingsdb_migration ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/generators/settingsdb/install_generator.rb', line 32 def add_settingsdb_migration return if !.migration? if migration_exists? migration_template 'migration_exists.rb', "db/migrate/settingsdb_add_settings_columns_to_#{table_name}" else migration_template 'migration.rb', "db/migrate/settingsdb_create_#{table_name}" end end |
#add_settingsdb_model ⇒ Object
22 23 24 25 |
# File 'lib/generators/settingsdb/install_generator.rb', line 22 def add_settingsdb_model return if !.model? || model_exists? invoke 'active_record:model', [name.singularize], :migration => false end |
#inject_settingsdb_content ⇒ Object
27 28 29 30 |
# File 'lib/generators/settingsdb/install_generator.rb', line 27 def inject_settingsdb_content return if !.model? inject_into_class(model_path, model_class, " acts_as_setting\n") end |