Sha256: 7b61018f57a754090cbd568996ae8bd906c33ea6ef178c89d253976c8a171bea

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

require "slack_bot/events/configuration"
require "slack_bot/events/client"
require "slack_bot/events/middleware/chain"
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

    def self.message_middleware
      config.message_middleware
    end

    def self.open_middleware
      config.open_middleware
    end

    def self.close_middleware
      config.close_middleware
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slack_bot-events-0.4.4 lib/slack_bot/events.rb
slack_bot-events-0.4.2 lib/slack_bot/events.rb
slack_bot-events-0.4.1 lib/slack_bot/events.rb