simple_notifications 1.1.2 → 1.1.3
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/Gemfile.lock +1 -1
- data/README.md +3 -1
- data/lib/simple_notifications/base.rb +8 -3
- 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: e1326347a5f7506473900145e99a4f850fd12d4087b195cd8c752d1ed3fb7f02
|
4
|
+
data.tar.gz: c14be795867013fbd067b477b81b741221c680eea743c604f6ba1f59fdc0a208
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b5680902fe2b5106059f48301869208c53e20f1fe561d68ed78f080f172e044d01ad7c98503a2061aef3fce1282971ba56939f6a5588b2250134a61ea2aed24
|
7
|
+
data.tar.gz: 8ac07714291ac4718140512d34bbbf4969f2af327943cdb64644eecc329e0365ef1033e2e041665dd65c392f3f55584cb314e49ab6aaa6ffb073a5f2b4cb7c23
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -84,6 +84,7 @@ Post.notified?
|
|
84
84
|
**Methods for the [post] object**
|
85
85
|
|
86
86
|
```ruby
|
87
|
+
post.notify
|
87
88
|
post.notify(sender: :author, receivers: :followers, message: 'My own message')
|
88
89
|
post.notifications
|
89
90
|
post.notifiers
|
@@ -119,7 +120,8 @@ SimpleNotifications::Record.last.#{receiver_class.name.downcase}_receivers
|
|
119
120
|
### Skipping Notification
|
120
121
|
|
121
122
|
```ruby
|
122
|
-
Post.create(content: '123',
|
123
|
+
Post.create(content: '123', notify_flag: false)
|
124
|
+
Post.create(content: '123', notify_flag: nil)
|
123
125
|
```
|
124
126
|
|
125
127
|
### Custom Notification message
|
@@ -47,7 +47,7 @@ module SimpleNotifications
|
|
47
47
|
def open_notified_class
|
48
48
|
class_eval do
|
49
49
|
prepend NotificationActions
|
50
|
-
attr_accessor :message, :
|
50
|
+
attr_accessor :message, :notify_flag
|
51
51
|
|
52
52
|
# Define association for the notified model
|
53
53
|
has_many :notifications, class_name: 'SimpleNotifications::Record', as: :entity
|
@@ -71,8 +71,11 @@ module SimpleNotifications
|
|
71
71
|
# has_many :read_notificants, through: :read_deliveries, source: :receiver, source_type: 'User'
|
72
72
|
# has_many :unread_notificants, through: :unread_deliveries, source: :receiver, source_type: 'User'
|
73
73
|
|
74
|
+
|
74
75
|
# Callbacks
|
75
|
-
@@options[:callbacks].
|
76
|
+
after_create_commit :create_notification, if: proc {@@options[:callbacks].include?(:create)}
|
77
|
+
after_update_commit :update_notification, if: proc {@@options[:callbacks].include?(:update)}
|
78
|
+
after_destroy_commit :destroy_notification, if: proc {@@options[:callbacks].include?(:destroy)}
|
76
79
|
|
77
80
|
NotificationActions.module_eval do
|
78
81
|
@@options[:actions].each do |action|
|
@@ -101,7 +104,9 @@ module SimpleNotifications
|
|
101
104
|
#post.notify(sender: :author, receivers: :followers, message: 'My Custom logic message')
|
102
105
|
#post.create(content: '', notify: false) -> It does not create the notification.
|
103
106
|
def notify(options = {})
|
104
|
-
|
107
|
+
options[:sender] ||= @@options[:sender]
|
108
|
+
options[:receivers] ||= @@options[:receivers]
|
109
|
+
if notify_flag.nil? || (!notify_flag.nil? && !!notify_flag)
|
105
110
|
raise 'SimpleNotification::SenderReceiverError' unless @@options[:sender] && @@options[:receivers]
|
106
111
|
@message = options[:message] if options[:message]
|
107
112
|
notification = notifications.build(entity: self, sender: get_obj(options[:sender]), message: default_message(self, get_obj(options[:sender]), 'created'))
|