Class: BoltRb::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/bolt_rb/configuration.rb

Overview

Configuration class for BoltRb applications

Holds all settings including tokens, handler paths, logger, middleware stack, and error handling configuration.

Examples:

Basic configuration

BoltRb.configure do |config|
  config.bot_token = ENV['SLACK_BOT_TOKEN']
  config.app_token = ENV['SLACK_APP_TOKEN']
  config.signing_secret = ENV['SLACK_SIGNING_SECRET']
end

Adding custom middleware

BoltRb.configure do |config|
  config.use MyCustomMiddleware
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



34
35
36
37
38
39
40
# File 'lib/bolt_rb/configuration.rb', line 34

def initialize
  @handler_paths = ['app/slack_handlers']
  @logger = Logger.new($stdout)
  @logger.level = Logger::INFO
  @middleware = [BoltRb::Middleware::Logging]
  @worker_threads = 5
end

Instance Attribute Details

#app_tokenObject

Returns the value of attribute app_token.



24
25
26
# File 'lib/bolt_rb/configuration.rb', line 24

def app_token
  @app_token
end

#assistant_thread_context_storeObject

Return the store for assistant thread context

Defaults to an in-process memory store. Any object that responds to get(channel_id:, thread_ts:) and save(channel_id:, thread_ts:, context:) can replace it.

Returns:

  • The thread context store



49
50
51
# File 'lib/bolt_rb/configuration.rb', line 49

def assistant_thread_context_store
  @assistant_thread_context_store ||= BoltRb::Assistant::MemoryThreadContextStore.new
end

#bot_tokenObject

Returns the value of attribute bot_token.



24
25
26
# File 'lib/bolt_rb/configuration.rb', line 24

def bot_token
  @bot_token
end

#error_handlerObject

Returns the value of attribute error_handler.



24
25
26
# File 'lib/bolt_rb/configuration.rb', line 24

def error_handler
  @error_handler
end

#handler_pathsObject

Returns the value of attribute handler_paths.



24
25
26
# File 'lib/bolt_rb/configuration.rb', line 24

def handler_paths
  @handler_paths
end

#loggerObject

Returns the value of attribute logger.



24
25
26
# File 'lib/bolt_rb/configuration.rb', line 24

def logger
  @logger
end

#middlewareObject (readonly)

Returns the value of attribute middleware.



32
33
34
# File 'lib/bolt_rb/configuration.rb', line 32

def middleware
  @middleware
end

#signing_secretObject

Returns the value of attribute signing_secret.



24
25
26
# File 'lib/bolt_rb/configuration.rb', line 24

def signing_secret
  @signing_secret
end

#worker_threadsInteger

Returns Number of threads that run handlers. Default 5.

Returns:

  • Number of threads that run handlers. Default 5.



28
29
30
# File 'lib/bolt_rb/configuration.rb', line 28

def worker_threads
  @worker_threads
end

Instance Method Details

#use(middleware_class) ⇒ Array<Class>

Add middleware to the stack

Parameters:

  • The middleware class to add

Returns:

  • The updated middleware stack



57
58
59
# File 'lib/bolt_rb/configuration.rb', line 57

def use(middleware_class)
  @middleware << middleware_class
end