Class: ViewGenerator

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

Instance Method Summary collapse

Instance Method Details

#create_root_directoryObject



7
8
9
# File 'lib/generators/view/view_generator.rb', line 7

def create_root_directory
  empty_directory(File.join('app/views', file_name)) if actions.empty?
end

#create_view_fileObject



11
12
13
14
15
16
17
18
# File 'lib/generators/view/view_generator.rb', line 11

def create_view_file
  return if actions.empty?

  actions.each do |filename|
    path = File.join('app/views', class_path, file_name, "#{filename}.html.erb")
    template('view.html.erb', path)
  end
end

#generate_locale_fileObject



20
21
22
# File 'lib/generators/view/view_generator.rb', line 20

def generate_locale_file
  invoke('locale:view', [name]) if configuration.autoload_view_generator_locale
end

#generate_test_fileObject



24
25
26
27
28
29
# File 'lib/generators/view/view_generator.rb', line 24

def generate_test_file
  framework = configuration.test_framework

  return if framework.nil?
  invoke("#{framework}:view", [name]) rescue nil
end