Class: ViewComponentGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/view_component/view_component_generator.rb

Overview

Instance Method Summary collapse

Instance Method Details

#create_component_fileObject



13
14
15
# File 'lib/generators/view_component/view_component_generator.rb', line 13

def create_component_file
  template "component.rb", File.join("app/frontend/components", class_path, file_name, "component.rb")
end

#create_preview_fileObject



33
34
35
36
37
# File 'lib/generators/view_component/view_component_generator.rb', line 33

def create_preview_file
  return if options[:skip_preview]

  template "preview.rb", File.join("app/frontend/components", class_path, file_name, "preview.rb")
end

#create_system_test_fileObject



27
28
29
30
31
# File 'lib/generators/view_component/view_component_generator.rb', line 27

def create_system_test_file
  return if options[:skip_system_test]

  template "component_system_test.rb", File.join("test/system/frontend/components", class_path, "#{file_name}_test.rb")
end

#create_template_fileObject



17
18
19
# File 'lib/generators/view_component/view_component_generator.rb', line 17

def create_template_file
  template "component.html.erb", File.join("app/frontend/components", class_path, file_name, "component.html.erb")
end

#create_test_fileObject



21
22
23
24
25
# File 'lib/generators/view_component/view_component_generator.rb', line 21

def create_test_file
  return if options[:skip_test]

  template "component_test.rb", File.join("test/frontend/components", class_path, "#{file_name}_test.rb")
end