simple_notifications 1.1.8 → 1.1.9
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 +26 -21
- 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: 734d3ac28915b2e74210cc06566ddeed980696f65f36300cc63925a684a56ca5
|
4
|
+
data.tar.gz: 739123957632324deb2cffe1d8edc9bff3826af6946fbd981b3b60e757d449ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a366d2e14de8e59c6456e4d3827b846cde3485c21d062ba30db017b16661e33986962f06eef1540f19014b65da0c24b2d6b5749ffaf4246d4b0920e4518e120c
|
7
|
+
data.tar.gz: e190dcf5be3dd5b4f567f6ab3c0e41dee297938aa64cc5227a295dd49214a098c24d18791ba0fe4f3ec3bdb2eaef7cf50ad41237138f80f6cb121f404c317ab6
|
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# Simple Notifications
|
2
2
|
|
3
3
|
A very simple gem providing the notifications functionality to any model in a Rails application.
|
4
|
+
It does not provide the push notifications.
|
5
|
+
|
6
|
+
It creates all the models/migrations/associations/callbacks for you.
|
4
7
|
|
5
8
|
### Installation
|
6
9
|
|
@@ -20,46 +23,47 @@ Or install it yourself as:
|
|
20
23
|
|
21
24
|
### Usage
|
22
25
|
|
23
|
-
|
26
|
+
* First run the simple notifications generator to generate two files in your rails project
|
27
|
+
|
28
|
+
* simple_notifications.rb - An initializer file.
|
29
|
+
* Migration files - Required for recording notifications.
|
24
30
|
|
25
31
|
```ruby
|
26
32
|
rails generate simple_notifications:install
|
27
33
|
```
|
28
|
-
This will generate two files in your rails project
|
29
|
-
|
30
|
-
* simple_notifications.rb - An initializer file.
|
31
|
-
* Migration files - Required for recording notifications.
|
32
34
|
|
33
|
-
|
35
|
+
* Migrate Database
|
34
36
|
|
35
37
|
```ruby
|
36
38
|
rails db:migrate
|
37
39
|
```
|
38
40
|
|
39
|
-
Add following line to the model for which notifications functionality is required.
|
41
|
+
Add the following line to the model for which notifications functionality is required.
|
42
|
+
Here [Post] is the model which is the base for notification to happen i.e Event is performed on Post.
|
40
43
|
|
41
44
|
```ruby
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
45
|
+
acts_as_notifier sender: :author,
|
46
|
+
receivers: :followers,
|
47
|
+
actions: [:follow, :unfollow, :update, :create, :destroy],
|
48
|
+
notify_message: :message_method,
|
49
|
+
before_notify: :before_notify_method,
|
50
|
+
after_notify: :after_notify_method,
|
51
|
+
before_delivered: :before_delivered_method,
|
52
|
+
after_delivered: :after_delivered_method,
|
53
|
+
before_read: :before_read_method,
|
54
|
+
after_read: :after_read_method
|
52
55
|
```
|
53
56
|
Here [receivers] will be notified that an event was done by [sender] on [post] entity with a message that is configurable.
|
54
57
|
|
55
58
|
You can also provide ActiveRecord::Base object or ActiveRecord::Relation objects as
|
56
59
|
|
57
60
|
```ruby
|
58
|
-
|
59
|
-
|
61
|
+
acts_as_notifier sender: :author, receivers: User.all, actions: [:create]
|
62
|
+
acts_as_notifier sender: User.first, receivers: [:followers, User.all], actions: [:create]
|
60
63
|
```
|
61
64
|
|
62
|
-
Here [:sender] is the [belongs_to] association with [:post] while :followers is the [:has_many] associations for the
|
65
|
+
Here [:sender] is the [belongs_to] association with [:post] while :followers is the [:has_many] associations for the
|
66
|
+
[:post] model through [:sender] model which needs to be notified.
|
63
67
|
|
64
68
|
### Notification Models
|
65
69
|
|
@@ -67,7 +71,8 @@ Here [:sender] is the [belongs_to] association with [:post] while :followers is
|
|
67
71
|
SimpleNotifications::Record
|
68
72
|
SimpleNotifications::Delivery
|
69
73
|
```
|
70
|
-
Here assumption is that one event performed by [:sender] on entity [:post] will have one type of notification
|
74
|
+
Here assumption is that one event performed by [:sender] on entity [:post] will have one type of notification
|
75
|
+
and it needs to be delivered to many [:receivers].
|
71
76
|
|
72
77
|
### Scopes
|
73
78
|
|