Class: ActiveRecord::Generators::ReleaseNotesGenerator
- Inherits:
-
Base
- Object
- Base
- ActiveRecord::Generators::ReleaseNotesGenerator
- Includes:
- ReleaseNotes::Generators::OrmHelpers
- Defined in:
- lib/generators/active_record/release_notes_generator.rb
Instance Method Summary collapse
- #copy_release_notes_migration ⇒ Object
- #generate_model ⇒ Object
- #inject_release_notes_content ⇒ Object
- #migration_data ⇒ Object
Methods included from ReleaseNotes::Generators::OrmHelpers
Instance Method Details
#copy_release_notes_migration ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/generators/active_record/release_notes_generator.rb', line 12 def copy_release_notes_migration if (behavior == :invoke && model_exists?) raise "#{table_name} already exists..." else migration_template "migration.rb", "db/migrate/release_notes_create_#{table_name}" end end |
#generate_model ⇒ Object
20 21 22 |
# File 'lib/generators/active_record/release_notes_generator.rb', line 20 def generate_model invoke "active_record:model", [name], :migration => false unless model_exists? && behavior == :invoke end |
#inject_release_notes_content ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/generators/active_record/release_notes_generator.rb', line 24 def inject_release_notes_content content = model_contents class_path = if namespaced? class_name.to_s.split("::") else [class_name] end indent_depth = class_path.size - 1 content = content.split("\n").map { |line| " " * indent_depth + line }.join("\n") << "\n" inject_into_class(model_path, class_path.last, content) if model_exists? end |
#migration_data ⇒ Object
39 40 41 42 43 44 |
# File 'lib/generators/active_record/release_notes_generator.rb', line 39 def migration_data "t.text :markdown, :null => false\nt.string :version, :null => false\n" end |