Class: Lotus::Generators::Mailer Private
- Defined in:
- lib/lotus/generators/mailer.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- TXT_FORMAT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'.txt'.freeze
- HTML_FORMAT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'.html'.freeze
- DEFAULT_ENGINE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'erb'.freeze
- DEFAULT_FROM =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"'<from>'".freeze
- DEFAULT_TO =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"'<to>'".freeze
- DEFAULT_SUBJECT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"'Hello'".freeze
Instance Method Summary collapse
- #__template_path(format) ⇒ Object private
- #_html_template_path ⇒ Object private
- #_mailer_path ⇒ Object private
- #_mailer_spec_path ⇒ Object private
- #_txt_template_path ⇒ Object private
- #assert_mailer! ⇒ Object private
-
#initialize(command) ⇒ Mailer
constructor
private
A new instance of Mailer.
- #name ⇒ Object private
- #start ⇒ Object private
Constructor Details
#initialize(command) ⇒ Mailer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Mailer.
36 37 38 39 40 41 |
# File 'lib/lotus/generators/mailer.rb', line 36 def initialize(command) super @mailer_name = Utils::String.new(name).classify cli.class.source_root(source) end |
Instance Method Details
#__template_path(format) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
101 102 103 |
# File 'lib/lotus/generators/mailer.rb', line 101 def __template_path(format) core_root.join('mailers', 'templates', "#{ name }#{ format }.#{ DEFAULT_ENGINE }") end |
#_html_template_path ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
95 96 97 |
# File 'lib/lotus/generators/mailer.rb', line 95 def _html_template_path __template_path(HTML_FORMAT) end |
#_mailer_path ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
77 78 79 |
# File 'lib/lotus/generators/mailer.rb', line 77 def _mailer_path core_root.join('mailers', "#{ name }.rb").to_s end |
#_mailer_spec_path ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
83 84 85 |
# File 'lib/lotus/generators/mailer.rb', line 83 def _mailer_spec_path spec_root.join(::File.basename(Dir.getwd), 'mailers', "#{ name }_spec.rb") end |
#_txt_template_path ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
89 90 91 |
# File 'lib/lotus/generators/mailer.rb', line 89 def _txt_template_path __template_path(TXT_FORMAT) end |
#assert_mailer! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
69 70 71 72 73 |
# File 'lib/lotus/generators/mailer.rb', line 69 def assert_mailer! if @mailer_name.nil? || @mailer_name.empty? raise Lotus::Commands::Generate::Error.new("Missing mailer name") end end |
#name ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
107 108 109 |
# File 'lib/lotus/generators/mailer.rb', line 107 def name Utils::String.new(app_name || super).underscore end |
#start ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/lotus/generators/mailer.rb', line 45 def start assert_mailer! opts = { mailer: @mailer_name, from: DEFAULT_FROM, to: DEFAULT_TO, subject: DEFAULT_SUBJECT, } templates = { 'mailer_spec.rb.tt' => _mailer_spec_path, 'mailer.rb.tt' => _mailer_path, 'template.txt.tt' => _txt_template_path, 'template.html.tt' => _html_template_path, } templates.each do |src, dst| cli.template(source.join(src), target.join(dst), opts) end end |