lib/maily/generator.rb in maily-0.7.2 vs lib/maily/generator.rb in maily-0.8.0
- old
+ new
@@ -5,17 +5,23 @@
fixtures = []
hooks = []
Maily::Mailer.list.each do |mailer|
- hooks << "\nMaily.hooks_for('#{mailer.name.classify}') do |mailer|"
+ _hooks = []
+
mailer.emails_list.each do |email|
if email.require_hook?
fixtures << email.required_arguments
- hooks << " mailer.register_hook(:#{email.name}, #{email.required_arguments.join(', ')})"
+ _hooks << " mailer.register_hook(:#{email.name}, #{email.required_arguments.join(', ')})"
end
end
- hooks << "end"
+
+ if _hooks.present?
+ hooks << "\nMaily.hooks_for('#{mailer.name.classify}') do |mailer|"
+ hooks << _hooks
+ hooks << "end"
+ end
end
fixtures = fixtures.flatten.uniq.map { |f| "#{f.to_s} = ''" }.join("\n")
hooks = hooks.join("\n")
\ No newline at end of file