Class: SendGrid::Attachment
- Inherits:
-
Object
- Object
- SendGrid::Attachment
- Defined in:
- lib/sendgrid/helpers/mail/attachment.rb
Instance Attribute Summary collapse
-
#content_id ⇒ Object
Returns the value of attribute content_id.
-
#disposition ⇒ Object
Returns the value of attribute disposition.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #content ⇒ Object
- #content=(content) ⇒ Object
-
#initialize ⇒ Attachment
constructor
A new instance of Attachment.
- #to_json ⇒ Object
Constructor Details
#initialize ⇒ Attachment
Returns a new instance of Attachment.
7 8 9 10 11 12 13 |
# File 'lib/sendgrid/helpers/mail/attachment.rb', line 7 def initialize @content = nil @type = nil @filename = nil @disposition = nil @content_id = nil end |
Instance Attribute Details
#content_id ⇒ Object
Returns the value of attribute content_id.
5 6 7 |
# File 'lib/sendgrid/helpers/mail/attachment.rb', line 5 def content_id @content_id end |
#disposition ⇒ Object
Returns the value of attribute disposition.
5 6 7 |
# File 'lib/sendgrid/helpers/mail/attachment.rb', line 5 def disposition @disposition end |
#filename ⇒ Object
Returns the value of attribute filename.
5 6 7 |
# File 'lib/sendgrid/helpers/mail/attachment.rb', line 5 def filename @filename end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/sendgrid/helpers/mail/attachment.rb', line 5 def type @type end |
Instance Method Details
#content ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/sendgrid/helpers/mail/attachment.rb', line 20 def content return @encoded_content if @encoded_content @encoded_content = if @content.respond_to?(:read) encode @content else @content end end |
#content=(content) ⇒ Object
15 16 17 18 |
# File 'lib/sendgrid/helpers/mail/attachment.rb', line 15 def content=(content) @encoded_content = nil @content = content end |
#to_json ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/sendgrid/helpers/mail/attachment.rb', line 30 def to_json(*) { 'content' => content, 'type' => type, 'filename' => filename, 'disposition' => disposition, 'content_id' => content_id }.delete_if { |_, value| value.to_s.strip == '' } end |