noticed 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 534fd7403e6eb6ad98672132d5c2b3ebf6de0eff7ada3a40ad9acc2bea2b7f2b
4
- data.tar.gz: 18973d1ff94fee48cc3daadd7a1e5df9bc104153dcd6ee10d9b5cfe98df832be
3
+ metadata.gz: a17ac9f27bd6d18637bb5f033f47bf19b452b33c77647729c27ad2f38239c9b6
4
+ data.tar.gz: ba7b0c12028132a9234ad32566dd005f870d8398db28287a7bdad6d53f59d79d
5
5
  SHA512:
6
- metadata.gz: 67cc5fe29f00612c81b64f70fd0b72d264d7f9d3486b14d0892a6482ac1ca75f06303d2bfd8aebfa349d145a269295b06e9530105ca2578d85d148ac5665eefb
7
- data.tar.gz: b66fa2922599a8edb40bdddf3a9a2a05debdfde299877140909fcb339895a0c94b2fa30c2a9d693026a4c040fcbd0c2cb1fdacaefcb328c845783694b04c4100
6
+ metadata.gz: af37b4d82f2f327d57cd0cc18271f8d84f7e38842f868c7ace8bb0c9a626161d4eec53e0c00363f1d4b21aaf8a8793eb197af88b76ab5630987366aa4e1c78e1
7
+ data.tar.gz: 733f9a0a51226f2ffce597c3f9e2ba36cb2befb62359c39f5f1b208e262d4900062753477bd5993f751db90e7c11218af050e1bd7c8295b9c7098eb0fb2907d7
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ### 🎉 Notifications for your Ruby on Rails app.
6
6
 
7
- [![Build Status](https://github.com/excid3/noticed/workflows/Tests/badge.svg)](https://github.com/excid3/noticed/actions)
7
+ [![Build Status](https://github.com/excid3/noticed/workflows/Tests/badge.svg)](https://github.com/excid3/noticed/actions) [![Gem Version](https://badge.fury.io/rb/noticed.svg)](https://badge.fury.io/rb/noticed)
8
8
 
9
9
  Currently, we support these notification delivery methods out of the box:
10
10
 
@@ -134,7 +134,7 @@ Defining custom delivery methods allows you to add callbacks that run inside the
134
134
 
135
135
  ##### Translations
136
136
 
137
- We've added `translate` and `t` helpers like Rails has to provide an easy way of scoping translations. If the key starts with a period, it will automatically scope the key under `notifications` and the underscored name of the notification class it is used in.
137
+ We've added `translate` and `t` helpers like Rails has to provide an easy way of scoping translations. If the key starts with a period, it will automatically scope the key under `notifications` and the underscored name of the notification class it is used in.
138
138
 
139
139
  For example:
140
140
 
@@ -176,6 +176,10 @@ Writes notification to the database.
176
176
 
177
177
  The name of the database association to use. Defaults to `:notifications`
178
178
 
179
+ * `format: :format_for_database` - *Optional*
180
+
181
+ Use a custom method to define the attributes saved to the database
182
+
179
183
  ### Email
180
184
 
181
185
  Sends an email notification. Emails will always be sent with `deliver_later`
@@ -192,6 +196,10 @@ Sends an email notification. Emails will always be sent with `deliver_later`
192
196
 
193
197
  Used to customize the method on the mailer that is called
194
198
 
199
+ * `format: :format_for_email` - *Optional*
200
+
201
+ Use a custom method to define the params sent to the mailer. `recipient` will be merged into the params.
202
+
195
203
  ### ActionCable
196
204
 
197
205
  Sends a notification to the browser via websockets (ActionCable channel by default).
@@ -264,7 +272,7 @@ Sends an SMS notification via Twilio.
264
272
 
265
273
  ### Vonage SMS
266
274
 
267
- Sends an SMS notification vai Vonage / Nexmo.
275
+ Sends an SMS notification via Vonage / Nexmo.
268
276
 
269
277
  `deliver_by :vonage`
270
278
 
@@ -9,7 +9,8 @@ module Noticed
9
9
  class_attribute :delivery_methods, instance_writer: false, default: []
10
10
  class_attribute :param_names, instance_writer: false, default: []
11
11
 
12
- attr_accessor :record
12
+ # Gives notifications access to the record and recipient when formatting for delivery
13
+ attr_accessor :record, :recipient
13
14
 
14
15
  class << self
15
16
  def deliver_by(name, options = {})
@@ -11,8 +11,9 @@ module Noticed
11
11
  @options = options
12
12
  @recipient = recipient
13
13
 
14
- # Keep track of the database record for rendering
14
+ # Make notification aware of database record and recipient during delivery
15
15
  @notification.record = record
16
+ @notification.recipient = recipient
16
17
 
17
18
  run_callbacks :deliver do
18
19
  deliver
@@ -2,7 +2,7 @@ module Noticed
2
2
  module DeliveryMethods
3
3
  class Email < Base
4
4
  def deliver
5
- mailer.with(notification.params).send(method.to_sym).deliver_later
5
+ mailer.with(format).send(method.to_sym).deliver_later
6
6
  end
7
7
 
8
8
  private
@@ -14,6 +14,14 @@ module Noticed
14
14
  def method
15
15
  options[:method] || notification.class.name.underscore
16
16
  end
17
+
18
+ def format
19
+ if (method = options[:format])
20
+ notification.send(method)
21
+ else
22
+ notification.params.merge(recipient: recipient)
23
+ end
24
+ end
17
25
  end
18
26
  end
19
27
  end
@@ -1,3 +1,3 @@
1
1
  module Noticed
2
- VERSION = "1.2.2"
2
+ VERSION = "1.2.3"
3
3
  end
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: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-03 00:00:00.000000000 Z
11
+ date: 2020-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails