Class: Noticed::DeliveryMethods::Base

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Callbacks
Defined in:
lib/noticed/delivery_methods/base.rb

Direct Known Subclasses

ActionCable, Database, Email, Slack, Test, Twilio, Vonage

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#notification ⇒ Object (readonly)

Returns the value of attribute notification.



7
8
9
# File 'lib/noticed/delivery_methods/base.rb', line 7

def notification
  @notification
end

#options ⇒ Object (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/noticed/delivery_methods/base.rb', line 7

def options
  @options
end

#recipient ⇒ Object (readonly)

Returns the value of attribute recipient.



7
8
9
# File 'lib/noticed/delivery_methods/base.rb', line 7

def recipient
  @recipient
end

Instance Method Details

#deliver ⇒ Object

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/noticed/delivery_methods/base.rb', line 22

def deliver
  raise NotImplementedError, "Delivery methods must implement a deliver method"
end

#perform(notification_class:, options:, params:, recipient:, record:) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/noticed/delivery_methods/base.rb', line 9

def perform(notification_class:, options:, params:, recipient:, record:)
  @notification = notification_class.constantize.new(params)
  @options = options
  @recipient = recipient

  # Keep track of the database record for rendering
  @notification.record = record

  run_callbacks :deliver do
    deliver
  end
end