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: f215fc7642db8db6a38ba3354c4d58ad1621c6d6af5c4ee479a519fdab1fae8d
4
- data.tar.gz: 874dc986fa682f54eaee86f0e8e638049cb8d4f310a2e4d906e76ba11b5d7405
3
+ metadata.gz: 6fca882449d4696c1551badc82383f789610f19898dec345a64f33a225ca9f81
4
+ data.tar.gz: 8751afe5063970449573719d7bedb957d7c88e52f1efef96357d8754d48cec21
5
5
  SHA512:
6
- metadata.gz: '039b85fe5977ecf3d3353ba275f0913f03a325a3affc913a5edc05f07e5555b38deff9fd23b492d16fbdaa58c0c5e3cf281267288c3ff69697d07e0ff840ded8'
7
- data.tar.gz: 7a49698a38596e35382fffc86d12857414f9f8ecdbc68f2c66fd24e124e6b893f62f442e736d004c5fad0403aa55eecc30a749843c6a61b5f0fc45d1b9da84c2
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
- You can define a custom delivery method easily by adding a `deliver_by` line with a unique name and class option. The class will be instantiated and should inherit from `Noticed::DeliveryMethods::Base`.
314
+ To generate a custom delivery method, simply run
315
315
 
316
- ```ruby
317
- class MyNotification < Noticed::Base
318
- deliver_by :discord, class: "DiscordNotification"
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 DiscordNotification < Noticed::DeliveryMethods::Base
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 DiscordNotification < Noticed::DeliveryMethods::Base
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 DiscordNotification
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: "DiscordNotification"
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
@@ -0,0 +1,5 @@
1
+ class DeliveryMethods::<%= class_name %> < Noticed::DeliveryMethods::Base
2
+ def deliver
3
+ # Logic for sending the notification
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module Noticed
2
- VERSION = "1.2.11"
2
+ VERSION = "1.2.12"
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.11
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-20 00:00:00.000000000 Z
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