noticed 2.3.0 → 2.4.0
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6c98658561b5afec24269bdf1f1a8217b000dcf4db2abb5007319833141edbd9
|
|
4
|
+
data.tar.gz: 99503d35717b87ae0cdad18d475bba9715ecaa4b84fbec49ee3be94237388c45
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7a85e749ddd781f5296cee3a891ed7a928e2c2051c80b44375509e4d39741e3e251a3a23665e623070f8f4a1beae9340cf696f9be1f1f1f6bc97363825ad2ed7
|
|
7
|
+
data.tar.gz: 71ed6f70d6770bc47f733ff290cdf0aecdae8083438707f018d6a0f215ec2fa104d97382e9f8faefe51db3662158da675f0c74ee11c188aad0e4c5380d83938e
|
|
@@ -6,17 +6,7 @@ module Noticed
|
|
|
6
6
|
class_attribute :bulk_delivery_methods, instance_writer: false, default: {}
|
|
7
7
|
class_attribute :delivery_methods, instance_writer: false, default: {}
|
|
8
8
|
class_attribute :required_param_names, instance_writer: false, default: []
|
|
9
|
-
|
|
10
|
-
attribute :params, default: {}
|
|
11
|
-
|
|
12
|
-
# Ephemeral notifiers cannot serialize params since they aren't ActiveRecord backed
|
|
13
|
-
if respond_to? :serialize
|
|
14
|
-
if Rails.gem_version >= Gem::Version.new("7.1.0.alpha")
|
|
15
|
-
serialize :params, coder: Coder
|
|
16
|
-
else
|
|
17
|
-
serialize :params, Coder
|
|
18
|
-
end
|
|
19
|
-
end
|
|
9
|
+
class_attribute :_recipients, instance_writer: false
|
|
20
10
|
end
|
|
21
11
|
|
|
22
12
|
class_methods do
|
|
@@ -50,6 +40,10 @@ module Noticed
|
|
|
50
40
|
delivery_methods[name] = DeliverBy.new(name, config)
|
|
51
41
|
end
|
|
52
42
|
|
|
43
|
+
def recipients(option = nil, &block)
|
|
44
|
+
self._recipients = block || option
|
|
45
|
+
end
|
|
46
|
+
|
|
53
47
|
def required_params(*names)
|
|
54
48
|
required_param_names.concat names
|
|
55
49
|
end
|
|
@@ -90,6 +84,8 @@ module Noticed
|
|
|
90
84
|
# CommentNotifier.deliver(User.all, wait: 5.minutes)
|
|
91
85
|
# CommentNotifier.deliver(User.all, wait_until: 1.hour.from_now)
|
|
92
86
|
def deliver(recipients = nil, enqueue_job: true, **options)
|
|
87
|
+
recipients ||= evaluate_recipients
|
|
88
|
+
|
|
93
89
|
validate!
|
|
94
90
|
|
|
95
91
|
transaction do
|
|
@@ -119,6 +115,16 @@ module Noticed
|
|
|
119
115
|
end
|
|
120
116
|
alias_method :deliver_later, :deliver
|
|
121
117
|
|
|
118
|
+
def evaluate_recipients
|
|
119
|
+
return unless _recipients
|
|
120
|
+
|
|
121
|
+
if _recipients.respond_to?(:call)
|
|
122
|
+
instance_exec(&_recipients)
|
|
123
|
+
elsif _recipients.is_a?(Symbol) && respond_to?(_recipients)
|
|
124
|
+
send(_recipients)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
122
128
|
def recipient_attributes_for(recipient)
|
|
123
129
|
{
|
|
124
130
|
type: "#{self.class.name}::Notification",
|
data/app/models/noticed/event.rb
CHANGED
|
@@ -11,5 +11,16 @@ module Noticed
|
|
|
11
11
|
accepts_nested_attributes_for :notifications
|
|
12
12
|
|
|
13
13
|
scope :newest_first, -> { order(created_at: :desc) }
|
|
14
|
+
|
|
15
|
+
attribute :params, :json, default: {}
|
|
16
|
+
|
|
17
|
+
# Ephemeral notifiers cannot serialize params since they aren't ActiveRecord backed
|
|
18
|
+
if respond_to? :serialize
|
|
19
|
+
if Rails.gem_version >= Gem::Version.new("7.1.0.alpha")
|
|
20
|
+
serialize :params, coder: Coder
|
|
21
|
+
else
|
|
22
|
+
serialize :params, Coder
|
|
23
|
+
end
|
|
24
|
+
end
|
|
14
25
|
end
|
|
15
26
|
end
|
|
@@ -13,8 +13,12 @@ module Noticed
|
|
|
13
13
|
|
|
14
14
|
desc "Generates a notification with the given NAME."
|
|
15
15
|
|
|
16
|
-
def
|
|
16
|
+
def generate_abstract_class
|
|
17
|
+
return if File.exist?("app/notifiers/application_notifier.rb")
|
|
17
18
|
template "application_notifier.rb", "app/notifiers/application_notifier.rb"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def generate_notification
|
|
18
22
|
template "notifier.rb", "app/notifiers/#{file_path}_notifier.rb"
|
|
19
23
|
end
|
|
20
24
|
|
|
@@ -7,7 +7,7 @@ module Noticed
|
|
|
7
7
|
mailer = fetch_constant(:mailer)
|
|
8
8
|
email = evaluate_option(:method)
|
|
9
9
|
args = evaluate_option(:args) || []
|
|
10
|
-
mail = mailer.with(params).
|
|
10
|
+
mail = mailer.with(params).public_send(email, *args)
|
|
11
11
|
(!!evaluate_option(:enqueue)) ? mail.deliver_later : mail.deliver_now
|
|
12
12
|
end
|
|
13
13
|
|
data/lib/noticed/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: noticed
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Oliver
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-
|
|
11
|
+
date: 2024-06-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
100
100
|
- !ruby/object:Gem::Version
|
|
101
101
|
version: '0'
|
|
102
102
|
requirements: []
|
|
103
|
-
rubygems_version: 3.5.
|
|
103
|
+
rubygems_version: 3.5.14
|
|
104
104
|
signing_key:
|
|
105
105
|
specification_version: 4
|
|
106
106
|
summary: Notifications for Ruby on Rails applications
|