Class: Workarea::ProductTemplateGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Workarea::ProductTemplateGenerator
- Defined in:
- lib/generators/workarea/product_template/product_template_generator.rb
Instance Method Summary collapse
- #add_template_to_workarea_initializer ⇒ Object
- #create_partial_template ⇒ Object
- #create_view_model ⇒ Object
Instance Method Details
#add_template_to_workarea_initializer ⇒ Object
6 7 8 9 10 |
# File 'lib/generators/workarea/product_template/product_template_generator.rb', line 6 def add_template_to_workarea_initializer inject_into_file 'config/initializers/workarea.rb', before: "\nend" do "\n\n\s\sconfig.product_templates << :#{file_name}" end end |
#create_partial_template ⇒ Object
12 13 14 15 16 |
# File 'lib/generators/workarea/product_template/product_template_generator.rb', line 12 def create_partial_template target_path = 'app/views/workarea/storefront/products/templates/' target_path += "_#{file_name}.html.haml" copy_file "#{Storefront::Engine.root}/app/views/workarea/storefront/products/templates/_generic.html.haml", target_path end |
#create_view_model ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/generators/workarea/product_template/product_template_generator.rb', line 18 def create_view_model return if ['skip-view-model'] target_path = 'app/view_models/workarea/storefront/product_templates/' target_path += "#{file_name}_view_model.rb" template 'view_model.rb.erb', target_path end |