simple_notifications 1.1.5 → 1.1.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.
- checksums.yaml +4 -4
- data/README.md +0 -2
- data/lib/simple_notifications/base.rb +10 -23
- data/lib/simple_notifications/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b68bdfc2e75a052f2ee8fb130cf00ab4b12ab311c4fd05a64765cb693083b214
|
4
|
+
data.tar.gz: 8497e5c83f7a11f8ca096f3c21e04da5eea965d353289dbc3dc2332a5bc0e01d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54a9962147cfacea84a7e8c03ee01472615e3cc178af61920365af53d4f4777d9327b1d16d679e51d63c946f706623599a9b06b6e1ffae2cc2dd40f3bb87195e
|
7
|
+
data.tar.gz: 80298c7efe237f9b8e5788b9b9d69aa214daed79a5859f70cd9d4ce0d2aa67f886f2c8a4e6290d887e5888c289129409a912ca3110ae59b4221b0e85a805b9f4
|
data/README.md
CHANGED
@@ -89,7 +89,6 @@ post.notify(sender: :author, receivers: :followers, message: 'My own message')
|
|
89
89
|
post.notifications
|
90
90
|
post.notifiers
|
91
91
|
post.notificants
|
92
|
-
post.#{receiver_class}_notificants
|
93
92
|
post.read_marked_notificants
|
94
93
|
post.unread_marked_notificants
|
95
94
|
post.mark_read
|
@@ -114,7 +113,6 @@ follower.received_notifications
|
|
114
113
|
```ruby
|
115
114
|
SimpleNotifications::Record.last.sender
|
116
115
|
SimpleNotifications::Record.last.entity
|
117
|
-
SimpleNotifications::Record.last.#{receiver_class.name.downcase}_receivers
|
118
116
|
```
|
119
117
|
|
120
118
|
### Skipping Notification
|
@@ -52,25 +52,8 @@ module SimpleNotifications
|
|
52
52
|
# Define association for the notified model
|
53
53
|
has_many :notifications, class_name: 'SimpleNotifications::Record', as: :entity
|
54
54
|
has_many :notifiers, through: :notifications, source: :sender, source_type: sender_class(@@options[:sender]).to_s
|
55
|
-
SimpleNotifications::Record.class_eval do
|
56
|
-
[@@options[:entity_class].receivers_class(@@options[:receivers])].flatten.each do |receiver_class|
|
57
|
-
has_many "#{receiver_class.name.downcase}_receivers".to_sym,
|
58
|
-
through: :deliveries,
|
59
|
-
source: :receiver,
|
60
|
-
source_type: receiver_class.name
|
61
|
-
end
|
62
|
-
end
|
63
|
-
[receivers_class(@@options[:receivers])].flatten.each do |receiver_class|
|
64
|
-
has_many "#{receiver_class.name.downcase}_notificants".to_sym,
|
65
|
-
through: :notifications,
|
66
|
-
source: "#{receiver_class.name.downcase}_receivers".to_sym
|
67
|
-
end
|
68
55
|
has_many :read_deliveries, through: :notifications, source: :read_deliveries
|
69
56
|
has_many :unread_deliveries, through: :notifications, source: :unread_deliveries
|
70
|
-
# has_many :notificants, through: :notifications, source: :receivers
|
71
|
-
# has_many :read_notificants, through: :read_deliveries, source: :receiver, source_type: 'User'
|
72
|
-
# has_many :unread_notificants, through: :unread_deliveries, source: :receiver, source_type: 'User'
|
73
|
-
|
74
57
|
|
75
58
|
# Callbacks
|
76
59
|
after_create_commit :create_notification, if: proc {@@options[:callbacks].include?(:create)}
|
@@ -125,18 +108,22 @@ module SimpleNotifications
|
|
125
108
|
end
|
126
109
|
|
127
110
|
def notificants
|
128
|
-
|
129
|
-
|
111
|
+
SimpleNotifications::Record.includes(deliveries: :receiver)
|
112
|
+
.collect(&:deliveries).flatten
|
113
|
+
.collect(&:receiver)
|
130
114
|
end
|
131
115
|
|
132
116
|
def read_marked_notificants
|
133
|
-
|
134
|
-
|
117
|
+
SimpleNotifications::Record.includes(deliveries: :receiver)
|
118
|
+
.collect(&:deliveries).flatten
|
119
|
+
.select{|record| record.is_read}
|
120
|
+
.collect(&:receiver)
|
135
121
|
end
|
136
122
|
|
137
123
|
def unread_marked_notificants
|
138
|
-
|
139
|
-
|
124
|
+
SimpleNotifications::Record.includes(deliveries: :receiver)
|
125
|
+
.collect(&:deliveries).flatten
|
126
|
+
.select{|record| !record.is_read}.collect(&:receiver)
|
140
127
|
end
|
141
128
|
|
142
129
|
# Mark notifications in read mode.
|