simple_notifications 1.1.6 → 1.1.7
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 +9 -7
- data/lib/simple_notifications/base.rb +1 -1
- data/lib/simple_notifications/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90315568f413c25998d564ad043f6895501daa5b727aff493d455ac5e26161af
|
4
|
+
data.tar.gz: fa75064e52508aca390b5e27b3fb2240b01852e77d8bd7aaac4cb4caac7f9e50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b27dab03d2c9cd13721808afd29a97e1408cc2229621601fabeaa604d2cbb0bde72f71e9d8f45271ffa328cced8ed78302630dcf0e25d38508597ef6ddf9ddb6
|
7
|
+
data.tar.gz: e6950c143a3b4098ab13ffce25bef39e44e0a89a5334f12dc617b388b0117277da94f2d09898490baa2411485d88ed2065815c7f48b0a6b1e7112a38f661df44
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# Simple Notifications
|
2
2
|
|
3
3
|
A very simple gem providing the notifications functionality to any model in a Rails application.
|
4
4
|
|
@@ -36,12 +36,12 @@ Then run
|
|
36
36
|
rails db:migrate
|
37
37
|
```
|
38
38
|
|
39
|
-
Add following line to the model for which notifications functionality is required
|
39
|
+
Add following line to the model for which notifications functionality is required. Here [Post] is the model which is the base for notification to happen i.e Event is performed on Post.
|
40
40
|
|
41
41
|
```ruby
|
42
42
|
notify sender: :author,
|
43
43
|
receivers: :followers,
|
44
|
-
actions: [:follow, :unfollow, :update],
|
44
|
+
actions: [:follow, :unfollow, :update, :create, :destroy],
|
45
45
|
notify_message: :message_method,
|
46
46
|
before_notify: :before_notify_method,
|
47
47
|
after_notify: :after_notify_method,
|
@@ -50,14 +50,16 @@ notify sender: :author,
|
|
50
50
|
before_read: :before_read_method,
|
51
51
|
after_read: :after_read_method
|
52
52
|
```
|
53
|
-
|
53
|
+
Here [receivers] will be notified that an event was done by [sender] on [post] entity with a message that is configurable.
|
54
|
+
|
55
|
+
You can also provide ActiveRecord::Base object or ActiveRecord::Relation objects as
|
54
56
|
|
55
57
|
```ruby
|
56
58
|
notify sender: :author, receivers: User.all
|
57
59
|
notify sender: User.first, receivers: [:followers, User.all]
|
58
60
|
```
|
59
61
|
|
60
|
-
Here :sender
|
62
|
+
Here [:sender] is the [belongs_to] association with [:post] while :followers is the [:has_many] associations for the [:post] model through [:sender] model which needs to be notified.
|
61
63
|
|
62
64
|
### Notification Models
|
63
65
|
|
@@ -65,6 +67,7 @@ Here :sender and :followers should be associations for the model which needs to
|
|
65
67
|
SimpleNotifications::Record
|
66
68
|
SimpleNotifications::Delivery
|
67
69
|
```
|
70
|
+
Here assumption is that one event performed by [:sender] on entity [:post] will have one type of notification and it needs to be delivered to many [:receivers].
|
68
71
|
|
69
72
|
### Scopes
|
70
73
|
|
@@ -74,8 +77,7 @@ SimpleNotifications::Record.unread
|
|
74
77
|
```
|
75
78
|
|
76
79
|
### Methods
|
77
|
-
|
78
|
-
Then following methods are available
|
80
|
+
Following are the method available
|
79
81
|
|
80
82
|
```ruby
|
81
83
|
Post.notified?
|
@@ -93,7 +93,7 @@ module SimpleNotifications
|
|
93
93
|
raise 'SimpleNotification::SenderReceiverError' unless @@options[:sender] && @@options[:receivers]
|
94
94
|
@message = options[:message] if options[:message]
|
95
95
|
notification = notifications.build(entity: self, sender: get_obj(options[:sender]), message: default_message(self, get_obj(options[:sender]), 'created'))
|
96
|
-
get_obj(options[:receivers]).each {|receiver| notification.deliveries.build(receiver: receiver)}
|
96
|
+
[get_obj(options[:receivers])].flatten.each {|receiver| notification.deliveries.build(receiver: receiver)}
|
97
97
|
notification.save
|
98
98
|
end
|
99
99
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_notifications
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ashish Garg
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -104,8 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
|
-
|
108
|
-
rubygems_version: 2.7.3
|
107
|
+
rubygems_version: 3.0.3
|
109
108
|
signing_key:
|
110
109
|
specification_version: 4
|
111
110
|
summary: A very simple gem providing the notifications functionality to any model
|