module Boppers

Constants

HttpClient
VERSION

Public Class Methods

configuration() click to toggle source
# File lib/boppers.rb, line 17
def self.configuration
  @configuration ||= Configuration.new
end
configure() { |configuration| ... } click to toggle source
# File lib/boppers.rb, line 13
def self.configure
  yield configuration
end
notify(name, title:, message:, options: {}) click to toggle source

Send notification. The `name` identifies the message type, which is used to filter out the notifications and their subscribers.

# File lib/boppers.rb, line 24
def self.notify(name, title:, message:, options: {})
  configuration
    .notifiers
    .select {|notifier| subscribed?(notifier, name) }
    .each do |notifier|
      notifier.call(title, message, options)
    end
end
subscribed?(notifier, name) click to toggle source
# File lib/boppers.rb, line 33
def self.subscribed?(notifier, name)
  subscriptions = if notifier.respond_to?(:subscribe)
                    [notifier.subscribe || name]
                  else
                    [name]
                  end
  subscriptions = subscriptions.flatten.compact.map(&:to_sym)

  subscriptions.include?(name)
end