class Hubspot::Mailer::HubspotPreviewInterceptor
Attributes
message[R]
Public Class Methods
new(message)
click to toggle source
# File lib/hubspot/mailer/hubspot_preview_interceptor.rb, line 12 def initialize(message) @message = message end
previewing_email(message)
click to toggle source
# File lib/hubspot/mailer/hubspot_preview_interceptor.rb, line 5 def previewing_email(message) new(message).transform! end
Public Instance Methods
transform!()
click to toggle source
# File lib/hubspot/mailer/hubspot_preview_interceptor.rb, line 16 def transform! build_preview end
Private Instance Methods
build_preview()
click to toggle source
# File lib/hubspot/mailer/hubspot_preview_interceptor.rb, line 22 def build_preview if message.message.is_a?(Hubspot::Mailer::Message) html_part = "<b>Email ID (template)</b>: #{message.email_id}<br/><br/>" html_part << list_properties("Contact Properties (use via {{contact.propertyname}})", message.contact_properties) html_part << list_properties("Custom Properties (use via {{custom.property_name}})", message.custom_properties) message.html_part = html_part end message end
list_properties(label, list)
click to toggle source
# File lib/hubspot/mailer/hubspot_preview_interceptor.rb, line 35 def list_properties(label, list) buffer = "" return buffer unless list.present? buffer << "<b>#{label}</b>:<ul>" list.each_pair do |property, value| buffer << "<li><i>#{property}</i>: #{value}</li>" end buffer << "</ul>" end