Skip to content

Commit b2f4e3c

Browse files
authored
Add docs for PR excid3#459 (excid3#482)
This adds info about excid3#459 to the README.
1 parent 6199c82 commit b2f4e3c

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.md

+28
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,34 @@ This invocation will create a single `Noticed::Event` record and a `Noticed::Not
399399
- An individual delivery job for `:email` method to the second thread author
400400
- Etc...
401401

402+
#### Tip: Define recipients inside the notifier
403+
404+
Recipients can also be computed inside a notifier:
405+
406+
```ruby
407+
class NewCommentNotifier < ApplicationNotifier
408+
recipients ->{ params[:record].thread.all_authors }
409+
410+
# or
411+
recipients do
412+
params[:record].thread.all_authors
413+
end
414+
415+
# or
416+
recipients :fetch_recipients
417+
418+
def fetch_recipients
419+
# ...
420+
end
421+
end
422+
```
423+
424+
This makes the code for sending a notification neater:
425+
426+
```ruby
427+
NewCommentNotifier.with(record: @comment, foo: "bar").deliver
428+
```
429+
402430
### Custom Noticed Model Methods
403431

404432
In order to extend the Noticed models you'll need to use a concern and a to_prepare block:

0 commit comments

Comments
 (0)