Class: Mailtrap::Mail::Base
- Inherits:
-
Object
- Object
- Mailtrap::Mail::Base
- Defined in:
- lib/mailtrap/mail/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#attachments ⇒ Object
Returns the value of attribute attachments.
-
#bcc ⇒ Object
Returns the value of attribute bcc.
-
#category ⇒ Object
Returns the value of attribute category.
-
#cc ⇒ Object
Returns the value of attribute cc.
-
#custom_variables ⇒ Object
Returns the value of attribute custom_variables.
-
#from ⇒ Object
Returns the value of attribute from.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#html ⇒ Object
Returns the value of attribute html.
-
#subject ⇒ Object
Returns the value of attribute subject.
-
#text ⇒ Object
Returns the value of attribute text.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
- #add_attachment(content:, filename:, type: nil, disposition: nil, content_id: nil) ⇒ Object
-
#as_json ⇒ Object
rubocop:disable Metrics/MethodLength.
-
#initialize(from: nil, to: [], cc: [], bcc: [], subject: nil, text: nil, html: nil, attachments: [], headers: {}, custom_variables: {}, category: nil) ⇒ Base
constructor
rubocop:disable Metrics/ParameterLists, Metrics/MethodLength.
- #to_json(*args) ⇒ Object
Constructor Details
#initialize(from: nil, to: [], cc: [], bcc: [], subject: nil, text: nil, html: nil, attachments: [], headers: {}, custom_variables: {}, category: nil) ⇒ Base
rubocop:disable Metrics/ParameterLists, Metrics/MethodLength
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mailtrap/mail/base.rb', line 11 def initialize( # rubocop:disable Metrics/ParameterLists, Metrics/MethodLength from: nil, to: [], cc: [], bcc: [], subject: nil, text: nil, html: nil, attachments: [], headers: {}, custom_variables: {}, category: nil ) @from = from @to = to @cc = cc @bcc = bcc @subject = subject @text = text @html = html self. = @headers = headers @custom_variables = custom_variables @category = category end |
Instance Attribute Details
#attachments ⇒ Object
Returns the value of attribute attachments.
9 10 11 |
# File 'lib/mailtrap/mail/base.rb', line 9 def @attachments end |
#bcc ⇒ Object
Returns the value of attribute bcc.
8 9 10 |
# File 'lib/mailtrap/mail/base.rb', line 8 def bcc @bcc end |
#category ⇒ Object
Returns the value of attribute category.
8 9 10 |
# File 'lib/mailtrap/mail/base.rb', line 8 def category @category end |
#cc ⇒ Object
Returns the value of attribute cc.
8 9 10 |
# File 'lib/mailtrap/mail/base.rb', line 8 def cc @cc end |
#custom_variables ⇒ Object
Returns the value of attribute custom_variables.
8 9 10 |
# File 'lib/mailtrap/mail/base.rb', line 8 def custom_variables @custom_variables end |
#from ⇒ Object
Returns the value of attribute from.
8 9 10 |
# File 'lib/mailtrap/mail/base.rb', line 8 def from @from end |
#headers ⇒ Object
Returns the value of attribute headers.
8 9 10 |
# File 'lib/mailtrap/mail/base.rb', line 8 def headers @headers end |
#html ⇒ Object
Returns the value of attribute html.
8 9 10 |
# File 'lib/mailtrap/mail/base.rb', line 8 def html @html end |
#subject ⇒ Object
Returns the value of attribute subject.
8 9 10 |
# File 'lib/mailtrap/mail/base.rb', line 8 def subject @subject end |
#text ⇒ Object
Returns the value of attribute text.
8 9 10 |
# File 'lib/mailtrap/mail/base.rb', line 8 def text @text end |
#to ⇒ Object
Returns the value of attribute to.
8 9 10 |
# File 'lib/mailtrap/mail/base.rb', line 8 def to @to end |
Instance Method Details
#add_attachment(content:, filename:, type: nil, disposition: nil, content_id: nil) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/mailtrap/mail/base.rb', line 65 def (content:, filename:, type: nil, disposition: nil, content_id: nil) = Mailtrap::Attachment.new( content: content, filename: filename, type: type, disposition: disposition, content_id: content_id ) << end |
#as_json ⇒ Object
rubocop:disable Metrics/MethodLength
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/mailtrap/mail/base.rb', line 37 def as_json # rubocop:disable Metrics/MethodLength { 'from' => from, 'to' => to, 'cc' => cc, 'bcc' => bcc, 'subject' => subject, 'text' => text, 'html' => html, 'attachments' => .map(&:as_json), # TODO: update headers and custom_variables with as_json method 'headers' => headers, 'custom_variables' => custom_variables, 'category' => category }.compact end |
#to_json(*args) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/mailtrap/mail/base.rb', line 54 def to_json(*args) JSON.generate( as_json, *args ) end |