2009-06-25 06:57:58 -04:00
|
|
|
module Rails
|
|
|
|
module Generators
|
|
|
|
class MailerGenerator < NamedBase
|
2010-04-30 06:42:12 -04:00
|
|
|
source_root File.expand_path("../templates", __FILE__)
|
|
|
|
|
2012-10-07 13:54:14 -04:00
|
|
|
argument :actions, type: :array, default: [], banner: "method method"
|
2014-12-17 13:18:22 -05:00
|
|
|
|
|
|
|
check_class_collision suffix: "Mailer"
|
2009-06-25 06:57:58 -04:00
|
|
|
|
|
|
|
def create_mailer_file
|
2014-12-17 13:18:22 -05:00
|
|
|
template "mailer.rb", File.join('app/mailers', class_path, "#{file_name}_mailer.rb")
|
2014-11-27 00:36:10 -05:00
|
|
|
if self.behavior == :invoke
|
|
|
|
template "application_mailer.rb", 'app/mailers/application_mailer.rb'
|
|
|
|
end
|
2009-06-25 06:57:58 -04:00
|
|
|
end
|
|
|
|
|
2009-06-27 08:27:26 -04:00
|
|
|
hook_for :template_engine, :test_framework
|
2014-12-17 13:18:22 -05:00
|
|
|
|
|
|
|
protected
|
|
|
|
def file_name
|
|
|
|
@_file_name ||= super.gsub(/\_mailer/i, '')
|
|
|
|
end
|
2009-06-25 06:57:58 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|