Class: ViewModelGenerator

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

Instance Method Summary collapse

Instance Method Details

#create_view_model_fileObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/generators/view_model_generator.rb', line 7

def create_view_model_file
  path = "app/view_models/#{file_name}.rb"

  if FileTest.exists? path
    raise FileExistError, "This filename ist used by another view-model:#{path}"
  end

  copy_file 'view_model_template.rb', path
  replace_class_name path
end

#create_view_model_test_fileObject



18
19
20
21
22
23
24
25
26
# File 'lib/generators/view_model_generator.rb', line 18

def create_view_model_test_file
  path = "test/view_models/#{file_name}_view_model_test.rb"
  if FileTest.exists?path
    raise FileExistError, "This filename ist used by another view-model test:#{path}"
  end

  copy_file "view_model_test_template.rb", path
  replace_class_name path
end