Class: Workarea::ProductTemplateGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/workarea/product_template/product_template_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_template_to_workarea_initializerObject



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_templateObject



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_modelObject



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 options['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