Module: MailerHelper

Defined in:
lib/mailer_helper.rb

Instance Method Summary collapse

Instance Method Details

#apply_radiant_layout(mailer_ivars = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/mailer_helper.rb', line 3

def apply_radiant_layout(mailer_ivars = {})
  message = MessagePage.new(:class_name => "MessagePage")
  layout = mailer_ivars[:@message_layout]
  layout = Layout.find_by_name(layout) unless layout.is_a? Layout
  message.layout = layout 
  message.title = @title || @content_for_title || message.title || ''
  message.build_parts_from_hash!(extract_captures)
  message.mailer_vars = mailer_ivars
  message.render
end

#extract_capturesObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/mailer_helper.rb', line 14

def extract_captures
  variables = instance_variables.grep(/@content_for_/)
  variables.inject({}) do |h, var|
    var =~ /^@content_for_(.*)$/
    key = $1.intern
    key = :body if key == :layout
    h[key] = instance_variable_get(var) unless key == :title
    h
  end
end