Sha256: 6e80eac2576554191c9a8ea302879193b78dd470e033d526e2299fc1eee771f6
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
module Maily module Generators class InstallGenerator < Rails::Generators::Base desc 'Maily installation: route and initializer' source_root File.expand_path("../../templates", __FILE__) def install generate_routing build_initializer end private def generate_routing route "mount Maily::Engine, at: 'maily'" end def build_initializer template 'initializer.rb', 'config/initializers/maily.rb' hooks = [] fixtures = [] Maily::Mailer.all.each do |mailer| hooks << "# Maily.hooks_for('#{mailer.name.classify}') do |mailer|" mailer.emails.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\n" end inject_into_file "config/initializers/maily.rb", after: "end\n" do "\n" + fixtures.flatten.uniq.map{ |f| f = "# #{f.to_s} = ''" }.join("\n") + "\n" + hooks.join("\n") end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
maily-0.1.0 | lib/generators/maily/install_generator.rb |