Class: FormMail
- Inherits:
-
Object
- Object
- FormMail
- Includes:
- Forms::Models::Extension
- Defined in:
- app/models/form_mail.rb
Instance Method Summary collapse
- #body ⇒ Object
- #cc ⇒ Object
- #charset ⇒ Object
- #content_type ⇒ Object
- #create ⇒ Object
- #from ⇒ Object
- #headers ⇒ Object
- #message ⇒ Object
- #recipients ⇒ Object
- #reply_to ⇒ Object
- #sender ⇒ Object
- #sent? ⇒ Boolean
- #subject ⇒ Object
Methods included from Forms::Models::Extension
Instance Method Details
#body ⇒ Object
73 74 75 76 77 78 79 80 81 |
# File 'app/models/form_mail.rb', line 73 def body # This parses the content of the form @parser = Radius::Parser.new(PageContext.new(@page), :tag_prefix => 'r') if @config[:body] @parser.parse(@form.send(@config[:body])) else @parser.parse(@form.content) end end |
#cc ⇒ Object
83 84 85 |
# File 'app/models/form_mail.rb', line 83 def cc @config[:cc] end |
#charset ⇒ Object
108 109 110 111 |
# File 'app/models/form_mail.rb', line 108 def charset charset = @config[:charset] || 'utf-8' charset = charset == '' ? nil : charset end |
#content_type ⇒ Object
104 105 106 |
# File 'app/models/form_mail.rb', line 104 def content_type content_type = @config[:content_type] || 'text/html' end |
#create ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/models/form_mail.rb', line 4 def create begin FormMailer.deliver_mail( :recipients => recipients, :from => from, :reply_to => reply_to, :subject => subject, :body => body, :cc => cc, :headers => headers, :content_type => content_type, :charset => charset, :config => @config ) @sent = true rescue Exception => exception raise exception if RAILS_ENV['development'] @message = exception @sent = false end @result = { :sent => self.sent?, :message => self., :subject => self.subject, :from => self.from } end |
#from ⇒ Object
33 34 35 36 37 38 39 |
# File 'app/models/form_mail.rb', line 33 def from begin Forms::Tags::Responses.retrieve(@data, @config[:field][:from]) rescue @config[:from] end end |
#headers ⇒ Object
95 96 97 98 99 100 101 102 |
# File 'app/models/form_mail.rb', line 95 def headers headers = { 'Reply-To' => reply_to } if sender headers['Return-Path'] = sender headers['Sender'] = sender end headers end |
#message ⇒ Object
91 92 93 |
# File 'app/models/form_mail.rb', line 91 def @message || nil end |
#recipients ⇒ Object
41 42 43 44 45 46 47 |
# File 'app/models/form_mail.rb', line 41 def recipients begin Forms::Tags::Responses.retrieve(@data, @config[:field][:to]) rescue @config[:to] end end |
#reply_to ⇒ Object
49 50 51 52 53 54 55 |
# File 'app/models/form_mail.rb', line 49 def reply_to begin Forms::Tags::Responses.retrieve(@data, @config[:field][:reply_to]) rescue @config[:reply_to] end end |
#sender ⇒ Object
57 58 59 60 61 62 63 |
# File 'app/models/form_mail.rb', line 57 def sender begin Forms::Tags::Responses.retrieve(@data, @config[:field][:sender]) rescue @config[:sender] end end |
#sent? ⇒ Boolean
87 88 89 |
# File 'app/models/form_mail.rb', line 87 def sent? @sent || false end |