Class: SupermarketSync::Notifier
- Inherits:
-
Object
- Object
- SupermarketSync::Notifier
- Defined in:
- lib/supermarket_sync/notifier.rb
Overview
> Notifications
Instance Attribute Summary collapse
-
#channels ⇒ Object
Returns the value of attribute channels.
-
#url ⇒ Object
Returns the value of attribute url.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#deprecated ⇒ Object
> Accumulators.
-
#initialize(**args) {|_self| ... } ⇒ Notifier
constructor
A new instance of Notifier.
- #send! ⇒ Object
- #slack ⇒ Object
- #updated ⇒ Object
Constructor Details
#initialize(**args) {|_self| ... } ⇒ Notifier
Returns a new instance of Notifier.
20 21 22 23 24 25 26 |
# File 'lib/supermarket_sync/notifier.rb', line 20 def initialize(**args) @url = args[:url] @channels = args[:channels] @username = args[:username] @http_opts = args[:http_opts] || {} yield self if block_given? end |
Instance Attribute Details
#channels ⇒ Object
Returns the value of attribute channels.
18 19 20 |
# File 'lib/supermarket_sync/notifier.rb', line 18 def channels @channels end |
#url ⇒ Object
Returns the value of attribute url.
18 19 20 |
# File 'lib/supermarket_sync/notifier.rb', line 18 def url @url end |
#username ⇒ Object
Returns the value of attribute username.
18 19 20 |
# File 'lib/supermarket_sync/notifier.rb', line 18 def username @username end |
Instance Method Details
#deprecated ⇒ Object
> Accumulators
49 50 51 |
# File 'lib/supermarket_sync/notifier.rb', line 49 def deprecated @deprecated ||= [] end |
#send! ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/supermarket_sync/notifier.rb', line 28 def send! = [build_deprecated, build_updated].compact return unless .any? Array(@channels).each do |channel| slack.ping '', attachments: , channel: channel end end |
#slack ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/supermarket_sync/notifier.rb', line 36 def slack (cfg = {})[:username] = @username cfg[:http_options] = { verify_mode: OpenSSL::SSL::VERIFY_NONE } Slack::Notifier.new @url do defaults cfg end end |
#updated ⇒ Object
53 54 55 |
# File 'lib/supermarket_sync/notifier.rb', line 53 def updated @updated ||= [] end |