Class: Contact::Form
- Inherits:
-
Object
- Object
- Contact::Form
- Includes:
- ActiveModel::Conversion, ActiveModel::Validations
- Defined in:
- app/models/contact/form.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#sender_email ⇒ Object
Returns the value of attribute sender_email.
-
#sender_name ⇒ Object
Returns the value of attribute sender_name.
-
#subject ⇒ Object
Returns the value of attribute subject.
Instance Method Summary collapse
- #from ⇒ Object
-
#initialize(attributes = {}) ⇒ Form
constructor
So we can batch update to instatiate the contact form, i.e.
- #persisted? ⇒ Boolean
Constructor Details
#initialize(attributes = {}) ⇒ Form
So we can batch update to instatiate the contact form, i.e. Contact.new(params)
15 16 17 18 19 |
# File 'app/models/contact/form.rb', line 15 def initialize(attributes = {}) attributes.each do |name, value| send("#{name}=", value) end end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
10 11 12 |
# File 'app/models/contact/form.rb', line 10 def body @body end |
#sender_email ⇒ Object
Returns the value of attribute sender_email.
10 11 12 |
# File 'app/models/contact/form.rb', line 10 def sender_email @sender_email end |
#sender_name ⇒ Object
Returns the value of attribute sender_name.
10 11 12 |
# File 'app/models/contact/form.rb', line 10 def sender_name @sender_name end |
#subject ⇒ Object
Returns the value of attribute subject.
10 11 12 |
# File 'app/models/contact/form.rb', line 10 def subject @subject end |
Instance Method Details
#from ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/models/contact/form.rb', line 21 def from case when self.sender_name.present? && self.sender_email.present? "#{self.sender_name} <#{self.sender_email}>" when self.sender_name.present? self.sender_name when self.sender_email.present? self.sender_email else "Annonymous User <#{CONTACT['default_recipients']}>" end end |
#persisted? ⇒ Boolean
34 35 36 |
# File 'app/models/contact/form.rb', line 34 def persisted? false end |