Class: AbstractNotifier::Notification

Inherits:
Object
  • Object
show all
Includes:
Testing::Notification
Defined in:
lib/abstract_notifier/base.rb

Overview

Notificaiton payload wrapper which contains information about the current notifier class and knows how to trigger the delivery

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(owner, payload) ⇒ Notification

Returns a new instance of Notification.



10
11
12
13
# File 'lib/abstract_notifier/base.rb', line 10

def initialize(owner, payload)
  @owner = owner
  @payload = payload
end

Instance Attribute Details

#ownerObject (readonly)

Returns the value of attribute owner.



8
9
10
# File 'lib/abstract_notifier/base.rb', line 8

def owner
  @owner
end

#payloadObject (readonly)

Returns the value of attribute payload.



8
9
10
# File 'lib/abstract_notifier/base.rb', line 8

def payload
  @payload
end

Instance Method Details

#notify_laterObject



15
16
17
18
# File 'lib/abstract_notifier/base.rb', line 15

def notify_later
  return if AbstractNotifier.noop?
  owner.async_adapter.enqueue owner, payload
end

#notify_nowObject



20
21
22
23
# File 'lib/abstract_notifier/base.rb', line 20

def notify_now
  return if AbstractNotifier.noop?
  owner.driver.call(payload)
end