Class: Draper::DecoratorGenerator

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

Constant Summary

DECORATORS_ROOT =
'app/decorators/'
APPLICATION_DECORATOR =
'application_decorator.rb'
APPLICATION_DECORATOR_PATH =
DECORATORS_ROOT + APPLICATION_DECORATOR

Instance Method Summary (collapse)

Instance Method Details

- (Object) build_model_and_application_decorators



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

def build_model_and_application_decorators
  empty_directory "app/decorators"
  unless File.exists?(APPLICATION_DECORATOR_PATH)
    template APPLICATION_DECORATOR, APPLICATION_DECORATOR_PATH
  end
  template 'decorator.rb', "#{DECORATORS_ROOT}#{singular_name}_decorator.rb"
end