noticed 1.2.11 → 1.2.12
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fca882449d4696c1551badc82383f789610f19898dec345a64f33a225ca9f81
|
4
|
+
data.tar.gz: 8751afe5063970449573719d7bedb957d7c88e52f1efef96357d8754d48cec21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ab4f29e4611ee0e5c3f548562e0265dc991ca45cb4789fbf7eb780430b21eddaef3407fbc7946f21bbff411149dd8e796197d9d0b334d85d8085aaea7beb54a
|
7
|
+
data.tar.gz: 7c6ce9b53092a182e405fc26274daae30e8ec6e2149c5f5794d3fa5c3728210f013f632c844dd00f9ad5f1d64cba12b09de6c311b9d367b580d91f899affb4c4
|
data/README.md
CHANGED
@@ -311,22 +311,28 @@ Sends an SMS notification via Vonage / Nexmo.
|
|
311
311
|
|
312
312
|
### 🚚 Custom Delivery Methods
|
313
313
|
|
314
|
-
|
314
|
+
To generate a custom delivery method, simply run
|
315
315
|
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
end
|
320
|
-
```
|
316
|
+
`rails generate noticed:delivery_method Discord`
|
317
|
+
|
318
|
+
This will generate a new `DeliveryMethods::Discord` class inside the `app/notifications/delivery_methods` folder, which can be used to deliver notifications to Discord.
|
321
319
|
|
322
320
|
```ruby
|
323
|
-
class
|
321
|
+
class DeliveryMethods::Discord < Noticed::DeliveryMethods::Base
|
324
322
|
def deliver
|
325
323
|
# Logic for sending a Discord notification
|
326
324
|
end
|
327
325
|
end
|
328
326
|
```
|
329
327
|
|
328
|
+
You can use the custom delivery method thus created by adding a `deliver_by` line with a unique name and `class` option in your notification class.
|
329
|
+
|
330
|
+
```ruby
|
331
|
+
class MyNotification < Noticed::Base
|
332
|
+
deliver_by :discord, class: "DeliveryMethods::Discord"
|
333
|
+
end
|
334
|
+
```
|
335
|
+
|
330
336
|
Delivery methods have access to the following methods and attributes:
|
331
337
|
|
332
338
|
* `notification` - The instance of the Notification. You can call methods on the notification to let the user easily override formatting and other functionality of the delivery method.
|
@@ -339,7 +345,7 @@ Delivery methods have access to the following methods and attributes:
|
|
339
345
|
Callbacks for delivery methods wrap the *actual* delivery of the notification. You can use `before_deliver`, `around_deliver` and `after_deliver` in your custom delivery methods.
|
340
346
|
|
341
347
|
```ruby
|
342
|
-
class
|
348
|
+
class DeliveryMethods::Discord < Noticed::DeliveryMethods::Base
|
343
349
|
after_deliver do
|
344
350
|
# Do whatever you want
|
345
351
|
end
|
@@ -351,13 +357,13 @@ end
|
|
351
357
|
Rails 6.1+ can serialize Class and Module objects as arguments to ActiveJob. The following syntax should work for Rails 6.1+:
|
352
358
|
|
353
359
|
```ruby
|
354
|
-
deliver_by
|
360
|
+
deliver_by DeliveryMethods::Discord
|
355
361
|
```
|
356
362
|
|
357
363
|
For Rails 6.0 and earlier, you must pass strings of the class names in the `deliver_by` options.
|
358
364
|
|
359
365
|
```ruby
|
360
|
-
deliver_by :discord, class: "
|
366
|
+
deliver_by :discord, class: "DeliveryMethods::Discord"
|
361
367
|
```
|
362
368
|
|
363
369
|
We recommend the Rails 6.0 compatible options to prevent confusion.
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/generators/named_base"
|
4
|
+
|
5
|
+
module Noticed
|
6
|
+
module Generators
|
7
|
+
class DeliveryMethodGenerator < Rails::Generators::NamedBase
|
8
|
+
include Rails::Generators::ResourceHelpers
|
9
|
+
|
10
|
+
source_root File.expand_path("../templates", __FILE__)
|
11
|
+
|
12
|
+
desc "Generates a class for a custom delivery method with the given NAME."
|
13
|
+
|
14
|
+
def generate_notification
|
15
|
+
template "delivery_method.rb", "app/notifications/delivery_methods/#{singular_name}.rb"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
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: 1.2.
|
4
|
+
version: 1.2.12
|
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-
|
11
|
+
date: 2020-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -92,9 +92,11 @@ files:
|
|
92
92
|
- README.md
|
93
93
|
- Rakefile
|
94
94
|
- app/channels/noticed/notification_channel.rb
|
95
|
+
- lib/generators/noticed/delivery_method_generator.rb
|
95
96
|
- lib/generators/noticed/model_generator.rb
|
96
97
|
- lib/generators/noticed/notification_generator.rb
|
97
98
|
- lib/generators/noticed/templates/README
|
99
|
+
- lib/generators/noticed/templates/delivery_method.rb.tt
|
98
100
|
- lib/generators/noticed/templates/notification.rb.tt
|
99
101
|
- lib/noticed.rb
|
100
102
|
- lib/noticed/base.rb
|