Class: Cms::Generators::ContentBlockGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Cms::Generators::ContentBlockGenerator
- Extended by:
- ActiveRecord::Generators::Migration
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/cms/content_block/content_block_generator.rb
Overview
Allows developers to create new Content Blocks for their projects.
Instance Method Summary collapse
-
#create_content_block ⇒ Object
Don’t check for class collision as overwriting content blocks is fine.
- #create_controller_and_views ⇒ Object
- #create_functional_test ⇒ Object
- #create_migration_file ⇒ Object
- #create_model_test ⇒ Object
- #create_routes ⇒ Object
Instance Method Details
#create_content_block ⇒ Object
Don’t check for class collision as overwriting content blocks is fine. check_class_collision
19 20 21 |
# File 'lib/generators/cms/content_block/content_block_generator.rb', line 19 def create_content_block template 'content_block.rb', File.join('app/models', "#{file_name}.rb") end |
#create_controller_and_views ⇒ Object
27 28 29 30 31 |
# File 'lib/generators/cms/content_block/content_block_generator.rb', line 27 def create_controller_and_views template 'controller.rb', File.join('app/controllers/cms', "#{file_name.pluralize}_controller.rb") template '_form.html.erb', File.join('app/views/cms/', file_name.pluralize, "_form.html.erb") template 'render.html.erb', File.join('app/views/cms/', file_name.pluralize, "render.html.erb") end |
#create_functional_test ⇒ Object
33 34 35 |
# File 'lib/generators/cms/content_block/content_block_generator.rb', line 33 def create_functional_test template 'functional_test.erb', File.join('test/functional/cms/', "#{file_name.pluralize}_controller_test.rb") end |
#create_migration_file ⇒ Object
41 42 43 44 |
# File 'lib/generators/cms/content_block/content_block_generator.rb', line 41 def create_migration_file return unless [:migration] migration_template "migration.erb", "db/migrate/create_#{table_name}.rb" end |
#create_model_test ⇒ Object
23 24 25 |
# File 'lib/generators/cms/content_block/content_block_generator.rb', line 23 def create_model_test template 'unit_test.erb', File.join('test', 'unit', 'models', "#{file_name}_test.rb") end |
#create_routes ⇒ Object
37 38 39 |
# File 'lib/generators/cms/content_block/content_block_generator.rb', line 37 def create_routes route "namespace :cms do content_blocks :#{file_name.pluralize} end\n" end |