Class: Martilla::Notifier
- Defined in:
- lib/martilla/notifier.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
-
.create(config = {}) ⇒ Object
When a new Notifier is supported it needs to go here.
Instance Method Summary collapse
- #error(msg, data) ⇒ Object
-
#initialize(config) ⇒ Notifier
constructor
A new instance of Notifier.
- #invalid_options_msg ⇒ Object
- #send_failure? ⇒ Boolean
- #send_success? ⇒ Boolean
- #success(data) ⇒ Object
Methods inherited from Component
Constructor Details
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/martilla/notifier.rb', line 3 def @options end |
Class Method Details
.create(config = {}) ⇒ Object
When a new Notifier is supported it needs to go here
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/martilla/notifier.rb', line 35 def self.create(config = {}) case config['type'].downcase when 'sendmail' Sendmail.new(config['options']) when 'smtp' Smtp.new(config['options']) when 'ses' Ses.new(config['options']) when 'slack' Slack.new(config['options']) when 'none' nil else raise Error.new("Invalid Notifier type: #{config['type']}") end end |
Instance Method Details
#error(msg, data) ⇒ Object
14 15 16 |
# File 'lib/martilla/notifier.rb', line 14 def error(msg, data) raise NotImplementedError, 'You must implement the error method' end |
#invalid_options_msg ⇒ Object
18 19 20 |
# File 'lib/martilla/notifier.rb', line 18 def 'Notifier configuration is invalid. Details here: https://github.com/fdoxyz/martilla' end |
#send_failure? ⇒ Boolean
28 29 30 31 32 |
# File 'lib/martilla/notifier.rb', line 28 def send_failure? value = @options['send_failure'] return true if value.nil? value end |
#send_success? ⇒ Boolean
22 23 24 25 26 |
# File 'lib/martilla/notifier.rb', line 22 def send_success? value = @options['send_success'] return true if value.nil? value end |
#success(data) ⇒ Object
10 11 12 |
# File 'lib/martilla/notifier.rb', line 10 def success(data) raise NotImplementedError, 'You must implement the success method' end |