Method: Noticed::DeliveryMethod#perform

Defined in:
lib/noticed/delivery_method.rb

#perform(delivery_method_name, notification, recipient: nil, params: {}, overrides: {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/noticed/delivery_method.rb', line 15

def perform(delivery_method_name, notification, recipient: nil, params: {}, overrides: {})
  # Ephemeral notifications
  if notification.is_a? String
    @notification = notification.constantize.new_with_params(recipient, params)
    @event = @notification.event
  else
    @notification = notification
    @event = notification.event
  end

  # Look up config from Notifier and merge overrides
  @config = event.delivery_methods.fetch(delivery_method_name).config.merge(overrides)

  return false if config.has_key?(:if) && !evaluate_option(:if)
  return false if config.has_key?(:unless) && evaluate_option(:unless)

  run_callbacks :deliver do
    deliver
  end
end