Sha256: 8ee6375b1393c242e7e3f907ef9bef7169ee883e275ef1bce8a624f319af45b0
Contents?: true
Size: 882 Bytes
Versions: 9
Compression:
Stored size: 882 Bytes
Contents
module Maily module Generator def self.run Maily.init! fixtures = [] hooks = [] Maily::Mailer.list.each 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(', ')})" end end if _hooks.present? hooks << "\nMaily.hooks_for('#{mailer.name.classify}') do |mailer|" hooks << _hooks hooks << "end" end end fixtures = fixtures.flatten.uniq.map do |fixture| argument = fixture.to_s value = argument.pluralize == argument ? '[]' : "''" [argument, value].join(' = ') end.join("\n") fixtures + "\n" + hooks.join("\n") + "\n" end end end
Version data entries
9 entries across 9 versions & 1 rubygems