Class: Trek::Generators::Install::PageGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Trek::Generators::Install::PageGenerator
- Includes:
- Rails::Generators::Migration, Helpers
- Defined in:
- lib/generators/trek/install/page_generator.rb
Constant Summary collapse
- PAGE_MODEL_CLASS_NAME =
"Page".freeze
Instance Method Summary collapse
- #copy_migration_file ⇒ Object
- #copy_model ⇒ Object
- #copy_page_path_model ⇒ Object
- #copy_page_paths_migration_file ⇒ Object
- #copy_page_version_model ⇒ Object
- #copy_page_versions_migration_file ⇒ Object
- #install_closure_tree ⇒ Object
Instance Method Details
#copy_migration_file ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/generators/trek/install/page_generator.rb', line 33 def copy_migration_file return unless defined?(ActiveRecord) migration_template("migrations/pages.rb.erb", "db/migrate/trek_pages.rb", migration_class_name:) end |
#copy_model ⇒ Object
18 19 20 21 |
# File 'lib/generators/trek/install/page_generator.rb', line 18 def copy_model template "models/page.rb", "app/models/page.rb" end |
#copy_page_path_model ⇒ Object
23 24 25 26 |
# File 'lib/generators/trek/install/page_generator.rb', line 23 def copy_page_path_model template "models/page_path.rb", "app/models/page_path.rb" end |
#copy_page_paths_migration_file ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/generators/trek/install/page_generator.rb', line 41 def copy_page_paths_migration_file return unless defined?(ActiveRecord) migration_template("migrations/page_paths.rb.erb", "db/migrate/trek_page_paths.rb", migration_class_name:) end |
#copy_page_version_model ⇒ Object
28 29 30 31 |
# File 'lib/generators/trek/install/page_generator.rb', line 28 def copy_page_version_model template "models/page_version.rb", "app/models/page_version.rb" end |
#copy_page_versions_migration_file ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/generators/trek/install/page_generator.rb', line 49 def copy_page_versions_migration_file return unless defined?(ActiveRecord) migration_template("migrations/page_versions.rb.erb", "db/migrate/trek_page_versions.rb", migration_class_name:) end |
#install_closure_tree ⇒ Object
57 58 59 60 61 62 |
# File 'lib/generators/trek/install/page_generator.rb', line 57 def install_closure_tree gem "closure_tree", "~> 9.0" unless in_gemfile?("closure_tree") run "bundle install --quiet", abort_on_failure: true rails_command "db:migrate" # `pages` table must exist generate "closure_tree:migration Page" end |