mailboxer 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +11 -1
- data/app/models/message.rb +5 -3
- data/app/models/notification.rb +3 -1
- data/mailboxer.gemspec +1 -1
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -67,4 +67,14 @@ In your model:
|
|
67
67
|
|
68
68
|
class User < ActiveRecord::Base
|
69
69
|
acts_as_messageable
|
70
|
-
end
|
70
|
+
end
|
71
|
+
|
72
|
+
You are not limited to User model. You can use Mailboxer in any other model and use it in serveral different models. If you have ducks and cylons in your application and you want to interchange messages as if they where the same, just use act_as_messageable in each one and you will be able to send duck-duck, duck-cylon, cylon-duck and cylon-cylon messages. Of course, you can extend it for as many clases as you need. Example:
|
73
|
+
|
74
|
+
class Duck < ActiveRecord::Base
|
75
|
+
acts_as_messageable
|
76
|
+
end
|
77
|
+
|
78
|
+
class Cylon < ActiveRecord::Base
|
79
|
+
acts_as_messageable
|
80
|
+
end
|
data/app/models/message.rb
CHANGED
@@ -30,7 +30,9 @@ class Message < Notification
|
|
30
30
|
temp_receipts << msg_receipt
|
31
31
|
#Should send an email?
|
32
32
|
if Mailboxer.uses_emails and r.send(Mailboxer.should_email_method,self)
|
33
|
-
|
33
|
+
unless r.send(Mailboxer.email_method).blank?
|
34
|
+
MessageMailer.send_email(self,r).deliver
|
35
|
+
end
|
34
36
|
end
|
35
37
|
end
|
36
38
|
#Sender receipt
|
@@ -45,9 +47,9 @@ class Message < Notification
|
|
45
47
|
if temp_receipts.all? { |t| t.errors.empty? }
|
46
48
|
temp_receipts.each(&:save!) #Save receipts
|
47
49
|
if reply
|
48
|
-
|
50
|
+
self.conversation.update_attribute(:updated_at, Time.now)
|
49
51
|
end
|
50
|
-
|
52
|
+
self.recipients=nil
|
51
53
|
self.on_deliver_callback.call(self) unless self.on_deliver_callback.nil?
|
52
54
|
end
|
53
55
|
return sender_receipt
|
data/app/models/notification.rb
CHANGED
@@ -44,7 +44,9 @@ class Notification < ActiveRecord::Base
|
|
44
44
|
temp_receipts << msg_receipt
|
45
45
|
#Should send an email?
|
46
46
|
if Mailboxer.uses_emails and r.send(Mailboxer.should_email_method,self)
|
47
|
-
|
47
|
+
unless r.send(Mailboxer.email_method).blank?
|
48
|
+
NotificationMailer.send_email(self,r).deliver
|
49
|
+
end
|
48
50
|
end
|
49
51
|
end
|
50
52
|
temp_receipts.each(&:valid?)
|
data/mailboxer.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "mailboxer"
|
3
|
-
s.version = "0.3.
|
3
|
+
s.version = "0.3.3"
|
4
4
|
s.authors = ["Eduardo Casanova Cuesta"]
|
5
5
|
s.summary = "Messaging system for rails apps."
|
6
6
|
s.description = "A Rails engine that allows any model to act as messageable, permitting it interchange messages with any other messageable model." +
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailboxer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 3
|
10
|
+
version: 0.3.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Eduardo Casanova Cuesta
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-07-
|
18
|
+
date: 2011-07-15 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|