mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
Don't attempt to overwrite an existing ApplicationDecorator
This commit is contained in:
parent
d7f154c978
commit
c0b05bf449
1 changed files with 8 additions and 2 deletions
|
@ -2,10 +2,16 @@ module Draper
|
|||
class ModelGenerator < Rails::Generators::NamedBase
|
||||
source_root File.expand_path('../templates', __FILE__)
|
||||
|
||||
DECORATORS_ROOT = 'app/decorators/'
|
||||
APPLICATION_DECORATOR = 'application_decorator.rb'
|
||||
APPLICATION_DECORATOR_PATH = DECORATORS_ROOT + APPLICATION_DECORATOR
|
||||
|
||||
def build_model_and_application_decorators
|
||||
empty_directory "app/decorators"
|
||||
template 'application_decorator.rb', 'app/decorators/application_decorator.rb'
|
||||
template 'model.rb', "app/decorators/#{singular_name}_decorator.rb"
|
||||
unless File.exists?(APPLICATION_DECORATOR_PATH)
|
||||
template APPLICATION_DECORATOR, APPLICATION_DECORATOR_PATH
|
||||
end
|
||||
template 'model.rb', "#{DECORATORS_ROOT}#{singular_name}_decorator.rb"
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue