Module: Tolliver::Models::NotificationDelivery

Extended by:
ActiveSupport::Concern
Included in:
NotificationDelivery
Defined in:
lib/tolliver/models/notification_delivery.rb

Instance Method Summary collapse

Instance Method Details

#deliverObject

*********************************************************************** Service ***********************************************************************



98
99
100
# File 'lib/tolliver/models/notification_delivery.rb', line 98

def deliver
  self.policy_service.deliver(self)
end

#doneObject

*********************************************************************** Progress ***********************************************************************



86
87
88
89
90
91
92
# File 'lib/tolliver/models/notification_delivery.rb', line 86

def done
  if self.sent_count && self.receivers_count
    self.sent_count.to_s + "/" + self.receivers_count.to_s
  else
    nil
  end
end

#method_serviceObject

*********************************************************************** Delivery method ***********************************************************************



53
54
55
56
57
58
# File 'lib/tolliver/models/notification_delivery.rb', line 53

def method_service
  if @method_service.nil?
    @method_service = "Tolliver::Services::Methods::#{self.method.to_s.capitalize}".constantize.new
  end
  @method_service
end

#policyObject

*********************************************************************** Policy ***********************************************************************



64
65
66
67
68
69
70
71
72
73
# File 'lib/tolliver/models/notification_delivery.rb', line 64

def policy
  case self.method.to_sym
  when :email then
    :batch
  when :sms then
    :batch
  else
    :instantly
  end
end

#policy_serviceObject



75
76
77
78
79
80
# File 'lib/tolliver/models/notification_delivery.rb', line 75

def policy_service
  if @policy_service.nil?
    @policy_service = "Tolliver::Services::Policies::#{self.policy.to_s.capitalize}".constantize.new
  end
  @policy_service
end