Skip to content

Commit

Permalink
Fixes for: README.md (#421)
Browse files Browse the repository at this point in the history
* Change sh to bash in README.md

* Fix indent

* Fix typo

* Fix indent

* Replace unicode spaces with spaces

* Add space

* Fix indent
  • Loading branch information
biow0lf authored Mar 6, 2024
1 parent d054cc9 commit b179d1c
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Noticed operates with a few constructs: Notifiers, delivery methods, and Notific

To start, generate a Notifier:

```sh
```bash
rails generate noticed:notifier NewCommentNotifier
```

Expand Down Expand Up @@ -202,12 +202,12 @@ class CommentNotifier < Noticed::Event
end
end

class Recipent < ApplicationRecord # or whatever your recipient model is
class Recipient < ApplicationRecord # or whatever your recipient model is
has_many :ios_device_tokens

def send_ios_notification?
# some logic
end
def send_ios_notification?
# some logic
end
end
```
</details>
Expand Down Expand Up @@ -297,9 +297,9 @@ Will look for the following translation path:

en:
notifiers:
new_comment_notifier:
notification:
message: "Someone posted a new comment!"
new_comment_notifier:
notification:
message: "Someone posted a new comment!"
```
Or, if you have your Notifier within another module, such as `Admin::NewCommentNotifier`, the resulting lookup path will be `en.notifiers.admin.new_comment_notifier.notification.message` (modules become nesting steps).
Expand Down Expand Up @@ -361,8 +361,8 @@ Each of these options are available for every delivery method (individual or bul
* `config.if` — Intended for a lambda or method; runs after the `wait` if configured; cancels the delivery method if returns falsey
* `config.unless` — Intended for a lambda or method; runs after the `wait` if configured; cancels the delivery method if returns truthy
* `config.wait` — (Should yield an `ActiveSupport::Duration`) Delays the job that runs this delivery method for the given duration of time
* `config.wait_until` (Should yield a specific time object) Delays the job that runs this delivery method until the specific time specified
* `config.queue` — Sets the ActiveJob queue name to be used for the job that runs this delivery method
* `config.wait_until` (Should yield a specific time object) Delays the job that runs this delivery method until the specific time specified
* `config.queue` — Sets the ActiveJob queue name to be used for the job that runs this delivery method

### 📨 Sending Notifications

Expand Down Expand Up @@ -489,7 +489,7 @@ Sending a notification is entirely an internal-to-your-app function. Delivery me
A common pattern is to deliver a notification via a real (or real-ish)-time service, then, after some time has passed, email the user if they have not yet read the notification. You can implement this functionality by combining multiple delivery methods, the `wait` option, and the conditional `if` / `unless` option.

```ruby
class NewCommentNotifier< Noticed::Event
class NewCommentNotifier < Noticed::Event
deliver_by :action_cable
deliver_by :email do |config|
config.mailer = "CommentMailer"
Expand Down Expand Up @@ -544,6 +544,7 @@ See the [Custom Noticed Model Methods](#custom-noticed-model-methods) section fo

```ruby
# app/notifiers/delivery_methods/turbo_stream.rb

class DeliveryMethods::TurboStream < ApplicationDeliveryMethod
def deliver
return unless recipient.is_a?(User)
Expand All @@ -557,6 +558,7 @@ end

```ruby
# app/models/concerns/noticed/notification_extensions.rb

module Noticed::NotificationExtensions
extend ActiveSupport::Concern

Expand Down Expand Up @@ -592,12 +594,12 @@ end

Delivery methods have access to the following methods and attributes:

* `event` The `Noticed::Event` record that spawned the notification object currently being delivered
* `record` The object originally passed into the Notifier as the `record:` param (see the ✨ note above)
* `notification` The `Noticed::Notification` instance being delivered. All notification helper methods are available on this object
* `recipient` The individual recipient object being delivered to for this notification (remember that each recipient gets their own instance of the Delivery Method `#deliver`)
* `config` The hash of configuration options declared by the Notifier that generated this notification and delivery
* `params` The parameters given to the Notifier in the invocation (via `.with()`)
* `event` The `Noticed::Event` record that spawned the notification object currently being delivered
* `record` The object originally passed into the Notifier as the `record:` param (see the ✨ note above)
* `notification` The `Noticed::Notification` instance being delivered. All notification helper methods are available on this object
* `recipient` The individual recipient object being delivered to for this notification (remember that each recipient gets their own instance of the Delivery Method `#deliver`)
* `config` The hash of configuration options declared by the Notifier that generated this notification and delivery
* `params` The parameters given to the Notifier in the invocation (via `.with()`)

#### Validating config options passed to Custom Delivery methods

Expand Down Expand Up @@ -628,7 +630,7 @@ class DeliveryMethods::WhatsApp < Noticed::DeliveryMethod

def deliver
# ...
config.day #=> #<Proc:0x000f7c8 (lambda)>
config.day #=> #<Proc:0x000f7c8 (lambda)>
evaluate_option(config.day) #=> "Tuesday"
end
end
Expand Down Expand Up @@ -803,4 +805,5 @@ DATABASE_URL=postgres://127.0.0.1/noticed_test rails test
```

## 📝 License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

0 comments on commit b179d1c

Please sign in to comment.