Class: Trek::Generators::Install::MailerGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Helpers
Defined in:
lib/generators/trek/install/mailer_generator.rb

Instance Method Summary collapse

Instance Method Details

#admin_mailerObject



22
23
24
25
# File 'lib/generators/trek/install/mailer_generator.rb', line 22

def admin_mailer
  template "mailers/admin_mailer.rb",
    "app/mailers/admin_mailer.rb"
end

#copy_views_admin_mailer_inviteObject



32
33
34
35
36
37
38
39
# File 'lib/generators/trek/install/mailer_generator.rb', line 32

def copy_views_admin_mailer_invite
  extensions.each do |extension|
    locales.each do |lang|
      template "views/admin_mailer/invite.#{lang}#{extension}",
        "app/views/admin_mailer/invite.#{lang}#{extension}"
    end
  end
end

#copy_views_passwords_mailer_resetObject



41
42
43
44
45
46
47
48
# File 'lib/generators/trek/install/mailer_generator.rb', line 41

def copy_views_passwords_mailer_reset
  extensions.each do |extension|
    locales.each do |lang|
      template "views/admin/passwords_mailer/reset.#{lang}#{extension}",
        "app/views/admin/passwords_mailer/reset.#{lang}#{extension}"
    end
  end
end

#mailer_templateObject



16
17
18
19
20
# File 'lib/generators/trek/install/mailer_generator.rb', line 16

def mailer_template
  remove_file "app/views/layouts/mailer.html.erb"
  template "layouts/mailer.html.slim",
    "app/views/layouts/mailer.html.slim"
end

#modify_application_mailerObject



50
51
52
# File 'lib/generators/trek/install/mailer_generator.rb', line 50

def modify_application_mailer
  gsub_file(application_mailer_file, /(default from: "from@example\.com")/, 'default from: email_address_with_name(ENV.fetch("MAILER_FROM", "from@example.com"), I18n.t("application_name"))')
end

#passwords_mailerObject



27
28
29
30
# File 'lib/generators/trek/install/mailer_generator.rb', line 27

def passwords_mailer
  template "mailers/admin/passwords_mailer.rb",
    "app/mailers/admin/passwords_mailer.rb"
end