Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defaults options to delivery methods #95

Closed
rafaelpivato opened this issue Feb 21, 2021 · 0 comments
Closed

Defaults options to delivery methods #95

rafaelpivato opened this issue Feb 21, 2021 · 0 comments

Comments

@rafaelpivato
Copy link

To favor sub-classing, allow default options to be defined for a notification. Here goes a suggestion:

class ApplicationNotification < Noticed::Base
  deliver_by_defaults :database, format: :database_format
  deliver_by_defaults :action_cable, format: :action_cable_format
  deliver_by_defaults :twilio, credentials: :twilio_credentials

  def database_format
    {
      'type': self.class.name,
      'params': params
    }
  end

  def action_cable_format
    params
  end

  def twilio_credentials
    {
      account_sid: ENV['TWILIO_ACCOUNT_SID'],
      auth_token: ENV['TWILIO_AUTH_TOKEN'],
      phone_number: ENV['TWILIO_PHONE_NUMBER']
    }
  end
end


class CommentCreatedNotification < ApplicationNotification
  deliver_by :database
  deliver_by :action_cable
  deliver_by :twilio
end

This wold work nice with #94 as well.

Repository owner locked and limited conversation to collaborators Oct 31, 2023
@Kentasmic Kentasmic converted this issue into discussion #340 Oct 31, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant