Class: Hanami::Commands::Generate::Mailer Private

Inherits:
Abstract show all
Defined in:
lib/hanami/commands/generate/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.

Since:

  • 0.5.0

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.

Since:

  • 0.5.0

".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.

Since:

  • 0.5.0

".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.

Since:

  • 0.5.0

"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.

Since:

  • 0.5.0

"'<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.

Since:

  • 0.5.0

"'<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.

Since:

  • 0.5.0

"'Hello'".freeze

Instance Attribute Summary collapse

Attributes inherited from Abstract

#options, #target_path

Instance Method Summary collapse

Methods inherited from Abstract

#template_source_path

Methods included from Generators::Generatable

#add_mapping, #argument_blank?, #destroy, #generator, #post_process_templates, #process_templates, #start, #target_path, #template_source_path

Methods inherited from Command

inherited

Constructor Details

#initialize(options, name) ⇒ 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

Since:

  • 0.5.0


38
39
40
41
42
43
44
45
46
47
48
# File 'lib/hanami/commands/generate/mailer.rb', line 38

def initialize(options, name)
  super(options)

  @name_underscored = Utils::String.new(name).underscore
  @name             = Utils::String.new(name_underscored).classify
  @from             = options[:from] || DEFAULT_FROM
  @to               = options[:to] || DEFAULT_TO
  @subject          = options[:subject] || DEFAULT_SUBJECT

  assert_name!
end

Instance Attribute Details

#fromObject (readonly)

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.

Since:

  • 0.5.0


10
11
12
# File 'lib/hanami/commands/generate/mailer.rb', line 10

def from
  @from
end

#nameObject (readonly)

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.

Since:

  • 0.5.0


10
11
12
# File 'lib/hanami/commands/generate/mailer.rb', line 10

def name
  @name
end

#name_underscoredObject (readonly)

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.

Since:

  • 0.5.0


10
11
12
# File 'lib/hanami/commands/generate/mailer.rb', line 10

def name_underscored
  @name_underscored
end

#subjectObject (readonly)

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.

Since:

  • 0.5.0


10
11
12
# File 'lib/hanami/commands/generate/mailer.rb', line 10

def subject
  @subject
end

#toObject (readonly)

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.

Since:

  • 0.5.0


10
11
12
# File 'lib/hanami/commands/generate/mailer.rb', line 10

def to
  @to
end

Instance Method Details

#map_templatesObject

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.

Since:

  • 0.x.x


52
53
54
55
56
57
# File 'lib/hanami/commands/generate/mailer.rb', line 52

def map_templates
  add_mapping("mailer_spec.rb.tt", mailer_spec_path)
  add_mapping("mailer.rb.tt", mailer_path)
  add_mapping("template.txt.tt", txt_template_path)
  add_mapping("template.html.tt", html_template_path)
end

#template_optionsObject

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.

Since:

  • 0.5.0


59
60
61
62
63
64
65
66
# File 'lib/hanami/commands/generate/mailer.rb', line 59

def template_options
  {
    mailer:  name,
    from:    from,
    to:      to,
    subject: subject,
  }
end