1
0
Fork 0
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:
Jeff Casimir 2011-07-29 20:33:39 -05:00
parent d7f154c978
commit c0b05bf449

View file

@ -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