Class: Pushing::NotificationDelivery

Inherits:
Delegator
  • Object
show all
Defined in:
lib/pushing/notification_delivery.rb

Instance Method Summary collapse

Constructor Details

#initialize(notifier_class, action, *args) ⇒ NotificationDelivery

:nodoc:



5
6
7
8
9
10
11
12
# File 'lib/pushing/notification_delivery.rb', line 5

def initialize(notifier_class, action, *args) #:nodoc:
  @notifier_class, @action, @args = notifier_class, action, args

  # The notification is only processed if we try to call any methods on it.
  # Typical usage will leave it unloaded and call deliver_later.
  @processed_notifier = nil
  @notification_message = nil
end

Instance Method Details

#__getobj__Object

:nodoc:



14
15
16
# File 'lib/pushing/notification_delivery.rb', line 14

def __getobj__ #:nodoc:
  @notification_message ||= processed_notifier.notification
end

#__setobj__(notification_message) ⇒ Object

Unused except for delegator internals (dup, marshaling).



19
20
21
# File 'lib/pushing/notification_delivery.rb', line 19

def __setobj__(notification_message) #:nodoc:
  @notification_message = notification_message
end

#deliver_later!(options = {}) ⇒ Object



31
32
33
# File 'lib/pushing/notification_delivery.rb', line 31

def deliver_later!(options = {})
  enqueue_delivery :deliver_now!, options
end

#deliver_now!Object



35
36
37
# File 'lib/pushing/notification_delivery.rb', line 35

def deliver_now!
  processed_notifier.handle_exceptions { do_deliver }
end

#messageObject



23
24
25
# File 'lib/pushing/notification_delivery.rb', line 23

def message
  __getobj__
end

#processed?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/pushing/notification_delivery.rb', line 27

def processed?
  @processed_notifier || @notification_message
end