class Postmortem::Adapters::Base
Base
interface implementation for all Postmortem
adapters.
Public Class Methods
new(data)
click to toggle source
# File lib/postmortem/adapters/base.rb, line 9 def initialize(data) @data = data @adapted = adapted end
Public Instance Methods
html_body()
click to toggle source
# File lib/postmortem/adapters/base.rb, line 32 def html_body @adapted[:html_body].to_s end
html_body=(val)
click to toggle source
# File lib/postmortem/adapters/base.rb, line 14 def html_body=(val) @adapted[:html_body] = val end
id()
click to toggle source
# File lib/postmortem/adapters/base.rb, line 22 def id @id ||= SecureRandom.uuid end
serializable()
click to toggle source
# File lib/postmortem/adapters/base.rb, line 18 def serializable (%i[id] + FIELDS).map { |field| [camelize(field.to_s), public_send(field)] }.to_h end
text_body()
click to toggle source
# File lib/postmortem/adapters/base.rb, line 36 def text_body @adapted[:text_body].to_s end
Private Instance Methods
adapted()
click to toggle source
# File lib/postmortem/adapters/base.rb, line 42 def adapted raise NotImplementedError, 'Adapter child class must implement #adapted' end
camelize(string)
click to toggle source
# File lib/postmortem/adapters/base.rb, line 46 def camelize(string) string .split('_') .each_with_index .map { |substring, index| index.zero? ? substring : substring.capitalize } .join end
html?()
click to toggle source
# File lib/postmortem/adapters/base.rb, line 76 def html? return true if mail.has_content_type? && mail.content_type.include?('text/html') return true if mail.multipart? && mail.html_part false end
html_part()
click to toggle source
# File lib/postmortem/adapters/base.rb, line 61 def html_part return nil unless html? return mail.body.decoded unless mail.html_part mail.html_part.decoded end
text?()
click to toggle source
# File lib/postmortem/adapters/base.rb, line 68 def text? return true unless mail.has_content_type? return true if mail.content_type.include?('text/plain') return true if mail.multipart? && mail.text_part false end
text_part()
click to toggle source
# File lib/postmortem/adapters/base.rb, line 54 def text_part return nil unless text? return mail.body.decoded unless mail.text_part mail.text_part.decoded end