mirror of
https://github.com/Evolix/chexpire.git
synced 2024-05-06 02:35:11 +02:00
ea610ee185
This is not dependent of Notificatioon model.
41 lines
1,021 B
Ruby
41 lines
1,021 B
Ruby
module Notifier
|
|
module Channels
|
|
class Base
|
|
def notify(notification) # rubocop:disable Metrics/MethodLength
|
|
return unless supports?(notification)
|
|
|
|
notification.ongoing!
|
|
|
|
case notification.check.kind.to_sym
|
|
when :domain
|
|
domain_notify_expires_soon(notification)
|
|
when :ssl
|
|
ssl_notify_expires_soon(notification)
|
|
else
|
|
fail ArgumentError,
|
|
"Invalid notification for check kind `#{notification.check.kind}`."
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
# :nocov:
|
|
def supports?(_notification)
|
|
fail NotImplementedError,
|
|
"#{self.class.name} channel did not implemented method #{__callee__}"
|
|
end
|
|
|
|
%i[
|
|
domain_notify_expires_soon
|
|
ssl_notify_expires_soon
|
|
].each do |method|
|
|
define_method(method) do
|
|
fail NotImplementedError,
|
|
"Channel #{self.class.name} does not implement method #{method}."
|
|
end
|
|
end
|
|
# :nocov:
|
|
end
|
|
end
|
|
end
|