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

#notificationObject (readonly)

Returns the value of attribute notification.



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

def notification
  @notification
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#recipientObject (readonly)

Returns the value of attribute recipient.



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

def recipient
  @recipient
end

#recordObject (readonly)

Returns the value of attribute record.



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

def record
  @record
end

Instance Method Details

#deliverObject

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/noticed/delivery_methods/base.rb', line 24

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

#perform(args) ⇒ Object



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

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

  # Make notification aware of database record and recipient during delivery
  @notification.record = args[:record]
  @notification.recipient = args[:recipient]

  run_callbacks :deliver do
    deliver
  end
end