Class: Mailtrap::Attachment

Inherits:
Object
  • Object
show all
Defined in:
lib/mailtrap/attachment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content:, filename:, type: nil, disposition: nil, content_id: nil) ⇒ Attachment

Returns a new instance of Attachment.



11
12
13
14
15
16
17
# File 'lib/mailtrap/attachment.rb', line 11

def initialize(content:, filename:, type: nil, disposition: nil, content_id: nil)
  self.content = content
  @type = type
  @filename = filename
  @disposition = disposition
  @content_id = content_id
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



9
10
11
# File 'lib/mailtrap/attachment.rb', line 9

def content
  @content
end

#content_idObject

Returns the value of attribute content_id.



8
9
10
# File 'lib/mailtrap/attachment.rb', line 8

def content_id
  @content_id
end

#dispositionObject

Returns the value of attribute disposition.



8
9
10
# File 'lib/mailtrap/attachment.rb', line 8

def disposition
  @disposition
end

#filenameObject

Returns the value of attribute filename.



8
9
10
# File 'lib/mailtrap/attachment.rb', line 8

def filename
  @filename
end

#typeObject

Returns the value of attribute type.



8
9
10
# File 'lib/mailtrap/attachment.rb', line 8

def type
  @type
end

Instance Method Details

#as_jsonObject



19
20
21
22
23
24
25
26
27
# File 'lib/mailtrap/attachment.rb', line 19

def as_json
  {
    'content' => content,
    'type' => type,
    'filename' => filename,
    'disposition' => disposition,
    'content_id' => content_id
  }.compact
end