Class: SendgridNotification::Attachment

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Attributes, ActiveModel::Model
Defined in:
app/models/sendgrid_notification/attachment.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.wrap(hash_or_attachment) ⇒ Object



28
29
30
31
32
33
34
35
# File 'app/models/sendgrid_notification/attachment.rb', line 28

def self.wrap(hash_or_attachment)
  case hash_or_attachment
  when Attachment
    self
  else
    Attachment.new(**hash_or_attachment.to_h)
  end
end

Instance Method Details

#as_sendgridObject



18
19
20
21
22
23
24
25
26
# File 'app/models/sendgrid_notification/attachment.rb', line 18

def as_sendgrid
  a = ::SendGrid::Attachment.new
  a.content_id = content_id
  a.filename = filename
  a.content = Base64.strict_encode64(content)
  a.type = mime_type
  a.disposition = disposition
  a
end