3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/maily/generator.rb', line 3
def self.run
Maily.init!
fixtures = []
hooks = []
Maily::Mailer.list.each do |mailer|
hooks << "\nMaily.hooks_for('#{mailer.name.classify}') do |mailer|"
mailer.emails_list.each do |email|
if email.require_hook?
fixtures << email.required_arguments
hooks << " mailer.register_hook(:#{email.name}, #{email.required_arguments.join(', ')})"
end
end
hooks << "end"
end
fixtures = fixtures.flatten.uniq.map { |f| "#{f.to_s} = ''" }.join("\n")
hooks = hooks.join("\n")
fixtures + "\n" + hooks + "\n"
end
|