Sha256: 71c15a5b482906172a8c2e773566c2d7ba7c546ab38fb8240e8353e5aad29fd1

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require "slack_bot/events/configuration"
require "slack_bot/events/client"
require "slack_bot/events/schemas/socket_payload"

module SlackBot
  module Events
    class Error < StandardError; end

    def self.configure
      yield configuration if block_given?
    end

    def self.configuration
      @configuration ||= SlackBot::Events::Configuration.new
    end

    def self.config
      configuration
    end

    def self.configuration=(object)
      if SlackBot::Events::Configuration === obj
        @configuration = object
        return @configuration
      end

      raise Error, "Expected configuration to be a SlackBot::Events::Configuration"
    end

    def self.register_listener(name:, handler:, on_success: nil, on_failure: nil)
      config.register_listener(name: name, handler: handler, on_success: on_success, on_failure: on_failure)
    end

    def self.remove_listener(name:)
      config.remove_listener(name: name)
    end

    def self.logger
      config.logger
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slack_bot-events-0.2.0 lib/slack_bot/events.rb
slack_bot-events-0.1.0 lib/slack_bot/events.rb