noticed 1.2.0 → 1.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c8f1abe201518056e73f223b840bb30f44e173181116c632217f5f5a4a4b4d5
4
- data.tar.gz: ba23af57eba01de7aecafd23c1ed00efacb8f354402592c68967f9f13c83a376
3
+ metadata.gz: a50bd43b89379867d1a76114bf3d306a9f7bb983e87ba9d8c293b34c5ed5fe7f
4
+ data.tar.gz: 2ac5422b2de7a9b4a7cde0ceddb2fb89eef13ed641fba3d4bff2d251a34fbfba
5
5
  SHA512:
6
- metadata.gz: 32fcb3681980b2e0ad9db0cbd26e47c8ff8c4b4524f5c1068da010b967c46524dcee78ec3809e622791768a1be08793fc7c159dae061e028ff3e707f89fe6f47
7
- data.tar.gz: f1d9d8318f4acb4ea77c8940f4e71bd91dd3ea40b70873741246109c472fc5164a5aa6be67fb22089b2bc6868601497c417ffb88cdb2e6ab92d1c195ab69ee58
6
+ metadata.gz: 856584e1f6045ca6db3badc0611066fcb709754008ec28806b4cf56b6be1f5ad62d7f6e8ee47ee181b446c19af1080e6352e2b551a8adf65e51a4d05e25d1c22
7
+ data.tar.gz: 2f4b8aa9183bbca49af5228f309a48448ffda1abf5ad302b405c1cafb43b82039a25b485c8d59dab4fdfe69242f247867cbdc6d4dad6fb21d7e4f09a7e1c015e
data/README.md CHANGED
@@ -81,6 +81,9 @@ notification.deliver_later(@comment.post.author)
81
81
 
82
82
  # Deliver notification immediately
83
83
  notification.deliver(@comment.post.author)
84
+
85
+ # Deliver notification to multiple recipients
86
+ notification.deliver_later(User.all)
84
87
  ```
85
88
 
86
89
  This will instantiate a new notification with the `comment` stored in the notification's params.
@@ -153,8 +156,6 @@ class CommentNotification < Noticed::Base
153
156
  end
154
157
  ```
155
158
 
156
- ###
157
-
158
159
  ## 🚛 Delivery Methods
159
160
 
160
161
  The delivery methods are designed to be modular so you can customize the way each type gets delivered.
data/lib/noticed/base.rb CHANGED
@@ -37,14 +37,24 @@ module Noticed
37
37
  @params = params
38
38
  end
39
39
 
40
- def deliver(recipient)
40
+ def deliver(recipients)
41
41
  validate!
42
- run_delivery(recipient, enqueue: false)
42
+
43
+ run_callbacks :deliver do
44
+ Array.wrap(recipients).each do |recipient|
45
+ run_delivery(recipient, enqueue: false)
46
+ end
47
+ end
43
48
  end
44
49
 
45
- def deliver_later(recipient)
50
+ def deliver_later(recipients)
46
51
  validate!
47
- run_delivery(recipient, enqueue: true)
52
+
53
+ run_callbacks :deliver do
54
+ Array.wrap(recipients).each do |recipient|
55
+ run_delivery(recipient, enqueue: true)
56
+ end
57
+ end
48
58
  end
49
59
 
50
60
  def params
@@ -55,18 +65,16 @@ module Noticed
55
65
 
56
66
  # Runs all delivery methods for a notification
57
67
  def run_delivery(recipient, enqueue: true)
58
- run_callbacks :deliver do
59
- delivery_methods = self.class.delivery_methods.dup
68
+ delivery_methods = self.class.delivery_methods.dup
60
69
 
61
- # Run database delivery inline first if it exists so other methods have access to the record
62
- if (index = delivery_methods.find_index { |m| m[:name] == :database })
63
- delivery_method = delivery_methods.delete_at(index)
64
- @record = run_delivery_method(delivery_method, recipient: recipient, enqueue: false)
65
- end
70
+ # Run database delivery inline first if it exists so other methods have access to the record
71
+ if (index = delivery_methods.find_index { |m| m[:name] == :database })
72
+ delivery_method = delivery_methods.delete_at(index)
73
+ @record = run_delivery_method(delivery_method, recipient: recipient, enqueue: false)
74
+ end
66
75
 
67
- delivery_methods.each do |delivery_method|
68
- run_delivery_method(delivery_method, recipient: recipient, enqueue: enqueue)
69
- end
76
+ delivery_methods.each do |delivery_method|
77
+ run_delivery_method(delivery_method, recipient: recipient, enqueue: enqueue)
70
78
  end
71
79
  end
72
80
 
@@ -1,3 +1,3 @@
1
1
  module Noticed
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noticed
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver