Class: Rooftop::Rails::Extras::ContactForm
- Inherits:
-
MailForm::Base
- Object
- MailForm::Base
- Rooftop::Rails::Extras::ContactForm
- Defined in:
- app/models/rooftop/rails/extras/contact_form.rb
Constant Summary collapse
- DEFAULT_FIELDS =
{ name: :text_field, email: :text_field, message: :text_area }
Class Attribute Summary collapse
-
.fields ⇒ Object
Returns the value of attribute fields.
-
.from ⇒ Object
Returns the value of attribute from.
-
.headers ⇒ Object
Returns the value of attribute headers.
-
.subject ⇒ Object
Returns the value of attribute subject.
-
.to ⇒ Object
Returns the value of attribute to.
Class Method Summary collapse
Instance Method Summary collapse
- #fields ⇒ Object
-
#headers ⇒ Object
Declare the e-mail headers.
Class Attribute Details
.fields ⇒ Object
Returns the value of attribute fields.
6 7 8 |
# File 'app/models/rooftop/rails/extras/contact_form.rb', line 6 def fields @fields end |
.from ⇒ Object
Returns the value of attribute from.
6 7 8 |
# File 'app/models/rooftop/rails/extras/contact_form.rb', line 6 def from @from end |
.headers ⇒ Object
Returns the value of attribute headers.
6 7 8 |
# File 'app/models/rooftop/rails/extras/contact_form.rb', line 6 def headers @headers end |
.subject ⇒ Object
Returns the value of attribute subject.
6 7 8 |
# File 'app/models/rooftop/rails/extras/contact_form.rb', line 6 def subject @subject end |
.to ⇒ Object
Returns the value of attribute to.
6 7 8 |
# File 'app/models/rooftop/rails/extras/contact_form.rb', line 6 def to @to end |
Class Method Details
.setup! ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/rooftop/rails/extras/contact_form.rb', line 15 def self.setup! (self.fields || DEFAULT_FIELDS).keys.each do |field| self.send(:attribute,field, {validate: true}) end self.subject ||= "Contact form message" self.to ||= "change.me@#{self.to_s.underscore}" self.from ||= "change.me@#{self.to_s.underscore}" self.headers ||= {} end |
Instance Method Details
#fields ⇒ Object
36 37 38 |
# File 'app/models/rooftop/rails/extras/contact_form.rb', line 36 def fields self.class.fields end |
#headers ⇒ Object
Declare the e-mail headers. It accepts anything the mail method in ActionMailer accepts.
28 29 30 31 32 33 34 |
# File 'app/models/rooftop/rails/extras/contact_form.rb', line 28 def headers { subject: self.class.subject, to: self.class.to, from: %("Contact form" <#{self.class.from}>) }.merge(self.class.headers) end |