Class: HtmlEmailCreator::Extensions

Inherits:
Object
  • Object
show all
Defined in:
lib/html_email_creator/extensions.rb

Constant Summary collapse

@@EXTENSIONS =
{
  'aweber' => {
    'email' => '{!email}',
    'subscription_date' => '{!signdate long}',
    'unsubscribe_url' => '{!remove_web}',
    'full_name' => '{!name_fix}',
    'first_name' => '{!firstname_fix}',
    'last_name' => '{!lastname_fix}',
    'signature' => '{!signature}',
    'company_address' => '{!contact_address}',
    'tomorrow' => '{!date dayname+1}',
    'after_2_days' => '{!date dayname+2}',
    'after_3_days' => '{!date dayname+3}',
    'after_4_days' => '{!date dayname+4}',
    'after_5_days' => '{!date dayname+5}',
    'after_6_days' => '{!date dayname+6}',
    'after_7_days' => '{!date dayname+7}'
  },
  'mailchimp' => {
    'email' => '*|EMAIL|*',
    'first_name' => '*|FNAME|*',
    'last_name' => '*|LNAME|*',
    'unsubscribe_url' => '*|UNSUB|*'
  }
}

Instance Method Summary collapse

Constructor Details

#initializeExtensions

This is a mechanism for handling HTML email for certain extension



33
34
# File 'lib/html_email_creator/extensions.rb', line 33

def initialize()
end

Instance Method Details

#built_in(*extensions) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/html_email_creator/extensions.rb', line 36

def built_in(*extensions)
  new_data = {}
  extensions.flatten.each do |extension|
    data = @@EXTENSIONS[extension]
    new_data.merge!(data.dup) if data
  end
  new_data
end

#custom(data = {}, extensions) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/html_email_creator/extensions.rb', line 45

def custom(data = {}, extensions)
  new_data = {}
  extensions.each_pair do |key, value|
    new_data[key] = value
  end
  new_data
end

#process_html(html, *extensions) ⇒ Object

HTML callback after the HTML is created.



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/html_email_creator/extensions.rb', line 54

def process_html(html, *extensions)
  processed_html = html.dup

  extensions.each do |extension|
    method_name = "process_html_for_#{extension}".to_sym

    if self.respond_to?(method_name)
      processed_html = self.send(method_name, html)
    end
  end

  processed_html
end