class SummonBot::Slack

Constants

PREFIX

Public Class Methods

method_missing(name) click to toggle source
# File lib/summon_bot/slack.rb, line 9
def method_missing(name)
  bot_names = ENV.keys.select { |k, _| k.include? PREFIX }.map { |k| k.gsub(Regexp.new("^#{PREFIX}"), '').downcase.to_sym }
  fail EnvNotFoundError, "Not found ENV: #{PREFIX}#{name.upcase}. Please check/set ENV." unless bot_names.include? name
  bot = notifier_class.new(ENV["#{PREFIX}#{name.upcase}"])

  def bot.speak(message, options = {})
    ping("[ENV=#{Rails.env}] #{message}", options)
  end

  bot
end
notifier_class() click to toggle source
# File lib/summon_bot/slack.rb, line 21
def notifier_class
  # For testing
  @notifier_class || ::Slack::Notifier
end