Class: Workarea::DecoratorGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/workarea/decorator/decorator_generator.rb

Instance Method Summary collapse

Instance Method Details



19
20
21
22
23
24
25
26
27
28
# File 'lib/generators/workarea/decorator/decorator_generator.rb', line 19

def copy_related_test_file
  return if decorating_test?
  original_test_path = find_existing_file(test_path)

  if original_test_path.present?
    template 'test_decorator.rb.erb', test_path.sub(rb_regex, '.decorator')
  else
    warn "No tests found for #{decorator_path}"
  end
end

#generate_decorator_fileObject



9
10
11
12
13
14
15
16
17
# File 'lib/generators/workarea/decorator/decorator_generator.rb', line 9

def generate_decorator_file
  original_path = find_existing_file(path)

  if original_path.present?
    template decorator_template, decorator_path
  else
    warn "No file found at #{path}"
  end
end