contact 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,38 @@
1
+ # Models Without the Database: http://railsbest.com/levels/2
2
+
3
+ module Contact
4
+ require 'contact/engine' if defined?(Rails)
5
+
6
+ class Form
7
+ include ActiveModel::Validations
8
+ include ActiveModel::Conversion # form_for helper needs to know if we are POSTing (create) or PUTing (update)
9
+
10
+ attr_accessor :sender_name, :sender_email, :subject, :body
11
+
12
+ validates :subject, :body, :presence => true
13
+
14
+ # So we can batch update to instatiate the contact form, i.e. Contact.new(params[:contact_form])
15
+ def initialize(attributes = {})
16
+ attributes.each do |name, value|
17
+ send("#{name}=", value)
18
+ end
19
+ end
20
+
21
+ def from
22
+ case
23
+ when self.sender_name.present? && self.sender_email.present?
24
+ "#{self.sender_name} <#{self.sender_email}>"
25
+ when self.sender_name.present?
26
+ self.sender_name
27
+ when self.sender_email.present?
28
+ self.sender_email
29
+ else
30
+ "Annonymous User <#{CONTACT['default_recipients']}>"
31
+ end
32
+ end
33
+
34
+ def persisted?
35
+ false
36
+ end
37
+ end
38
+ end
data/contact-0.0.5.gem ADDED
Binary file
@@ -1,3 +1,3 @@
1
1
  module Contact
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contact
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jason Younker
@@ -66,7 +66,7 @@ files:
66
66
  - app/controllers/contact/contacts_controller.rb
67
67
  - app/helpers/application_helper.rb
68
68
  - app/mailers/mailer.rb
69
- - app/models/form.rb
69
+ - app/models/contact/form.rb
70
70
  - app/views/contact/contacts/new.haml
71
71
  - app/views/layouts/application.html.erb
72
72
  - app/views/mailer/contact_us.html.haml
@@ -89,6 +89,7 @@ files:
89
89
  - contact-0.0.2.gem
90
90
  - contact-0.0.3.gem
91
91
  - contact-0.0.4.gem
92
+ - contact-0.0.5.gem
92
93
  - contact.gemspec
93
94
  - db/seeds.rb
94
95
  - doc/README_FOR_APP
data/app/models/form.rb DELETED
@@ -1,34 +0,0 @@
1
- # Models Without the Database: http://railsbest.com/levels/2
2
- class Form
3
- include ActiveModel::Validations
4
- include ActiveModel::Conversion # form_for helper needs to know if we are POSTing (create) or PUTing (update)
5
-
6
- attr_accessor :sender_name, :sender_email, :subject, :body
7
-
8
- validates :subject, :body, :presence => true
9
-
10
- # So we can batch update to instatiate the contact form, i.e. Contact.new(params[:contact_form])
11
- def initialize(attributes = {})
12
- attributes.each do |name, value|
13
- send("#{name}=", value)
14
- end
15
- end
16
-
17
- def from
18
- case
19
- when self.sender_name.present? && self.sender_email.present?
20
- "#{self.sender_name} <#{self.sender_email}>"
21
- when self.sender_name.present?
22
- self.sender_name
23
- when self.sender_email.present?
24
- self.sender_email
25
- else
26
- "Annonymous User <#{CONTACT['default_recipients']}>"
27
- end
28
- end
29
-
30
- def persisted?
31
- false
32
- end
33
- end
34
-