Class: SlackBot::Config
- Inherits:
-
Object
- Object
- SlackBot::Config
- Defined in:
- lib/slack_bot/config.rb,
sig/slack_bot.rbs
Instance Attribute Summary collapse
-
#callback_storage_instance ⇒ Object
readonly
Returns the value of attribute callback_storage_instance.
-
#callback_user_finder_method ⇒ Proc
readonly
Returns the value of attribute callback_user_finder_method.
-
#event_dispatcher_method ⇒ Proc
readonly
Returns the value of attribute event_dispatcher_method.
-
#user_session_resolver_method ⇒ Proc
readonly
Returns the value of attribute user_session_resolver_method.
Class Method Summary collapse
Instance Method Summary collapse
- #block_action(action_id, interaction_klass, handler_name: nil) ⇒ void
- #callback_storage(klass) ⇒ void
- #callback_storage! ⇒ Object
- #callback_user_finder(method_lambda) ⇒ void
- #callback_user_finder! ⇒ Proc
- #event(event_type, event_klass, handler_name: nil) ⇒ void
- #event_dispatcher(method_lambda) ⇒ void
- #event_handlers ⇒ Hash[Symbol, Class]
- #find_block_action(action_id) ⇒ Class?
- #find_event_handler(event_type) ⇒ Class?
- #find_handler_class(class_name) ⇒ Class
- #find_menu_options(action_id) ⇒ Class?
- #find_slash_command_config(url_token, command, text) ⇒ SlashCommandConfig?
- #handler_class(class_name, klass) ⇒ void
- #interaction(interaction_klass, handler_name: nil) ⇒ void
- #menu_options(action_id, klass) ⇒ void
- #slash_command_endpoint(url_token, command_klass = nil, handler_name: nil) {|arg0| ... } ⇒ SlashCommandEndpointConfig
- #slash_command_endpoints ⇒ Hash[Symbol, SlashCommandEndpointConfig]
- #user_session_resolver(method_lambda) ⇒ void
- #user_session_resolver! ⇒ Proc
Instance Attribute Details
#callback_storage_instance ⇒ Object (readonly)
Returns the value of attribute callback_storage_instance.
15 16 17 |
# File 'lib/slack_bot/config.rb', line 15 def callback_storage_instance @callback_storage_instance end |
#callback_user_finder_method ⇒ Proc (readonly)
Returns the value of attribute callback_user_finder_method.
28 29 30 |
# File 'lib/slack_bot/config.rb', line 28 def callback_user_finder_method @callback_user_finder_method end |
#event_dispatcher_method ⇒ Proc (readonly)
Returns the value of attribute event_dispatcher_method.
54 55 56 |
# File 'lib/slack_bot/config.rb', line 54 def event_dispatcher_method @event_dispatcher_method end |
#user_session_resolver_method ⇒ Proc (readonly)
Returns the value of attribute user_session_resolver_method.
41 42 43 |
# File 'lib/slack_bot/config.rb', line 41 def user_session_resolver_method @user_session_resolver_method end |
Class Method Details
.configure {|arg0| ... } ⇒ void
This method returns an undefined value.
11 12 13 |
# File 'lib/slack_bot/config.rb', line 11 def self.configure(&) current_instance.instance_eval(&) end |
.current_instance ⇒ Config
6 7 8 9 |
# File 'lib/slack_bot/config.rb', line 6 def self.current_instance @@current_instances ||= {} @@current_instances[name] ||= new end |
Instance Method Details
#block_action(action_id, interaction_klass, handler_name: nil) ⇒ void
This method returns an undefined value.
115 116 117 118 119 |
# File 'lib/slack_bot/config.rb', line 115 def block_action(action_id, interaction_klass, handler_name: nil) @block_actions ||= {} @block_actions[action_id.to_sym] = interaction_klass interaction(interaction_klass, handler_name: handler_name) end |
#callback_storage(klass) ⇒ void
This method returns an undefined value.
16 17 18 |
# File 'lib/slack_bot/config.rb', line 16 def callback_storage(klass) @callback_storage_instance = klass end |
#callback_storage! ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/slack_bot/config.rb', line 20 def callback_storage! return @callback_storage_instance if @callback_storage_instance raise SlackBot::Errors::ConfigurationError.new( "callback_storage is not configured; call SlackBot::Config.configure { |config| config.callback_storage ... }" ) end |
#callback_user_finder(method_lambda) ⇒ void
This method returns an undefined value.
29 30 31 |
# File 'lib/slack_bot/config.rb', line 29 def callback_user_finder(method_lambda) @callback_user_finder_method = method_lambda end |
#callback_user_finder! ⇒ Proc
33 34 35 36 37 38 39 |
# File 'lib/slack_bot/config.rb', line 33 def callback_user_finder! return @callback_user_finder_method if @callback_user_finder_method raise SlackBot::Errors::ConfigurationError.new( "callback_user_finder is not configured; call SlackBot::Config.configure { |config| config.callback_user_finder ... }" ) end |
#event(event_type, event_klass, handler_name: nil) ⇒ void
This method returns an undefined value.
68 69 70 71 72 |
# File 'lib/slack_bot/config.rb', line 68 def event(event_type, event_klass, handler_name: nil) handler_name ||= event_klass.name handler_class(handler_name, event_klass) event_handlers[event_type.to_sym] = event_klass end |
#event_dispatcher(method_lambda) ⇒ void
This method returns an undefined value.
55 56 57 |
# File 'lib/slack_bot/config.rb', line 55 def event_dispatcher(method_lambda) @event_dispatcher_method = method_lambda end |
#event_handlers ⇒ Hash[Symbol, Class]
64 65 66 |
# File 'lib/slack_bot/config.rb', line 64 def event_handlers @event_handlers ||= {} end |
#find_block_action(action_id) ⇒ Class?
121 122 123 124 |
# File 'lib/slack_bot/config.rb', line 121 def find_block_action(action_id) @block_actions ||= {} @block_actions[action_id.to_sym] end |
#find_event_handler(event_type) ⇒ Class?
74 75 76 |
# File 'lib/slack_bot/config.rb', line 74 def find_event_handler(event_type) event_handlers[event_type.to_sym] end |
#find_handler_class(class_name) ⇒ Class
133 134 135 136 137 138 139 140 |
# File 'lib/slack_bot/config.rb', line 133 def find_handler_class(class_name) @handler_classes ||= {} return if class_name.nil? @handler_classes.fetch(class_name.to_sym) rescue KeyError raise SlackBot::Errors::HandlerClassNotFound.new(class_name, handler_classes: @handler_classes) end |
#find_menu_options(action_id) ⇒ Class?
110 111 112 113 |
# File 'lib/slack_bot/config.rb', line 110 def (action_id) @menu_options ||= {} @menu_options[action_id.to_sym] end |
#find_slash_command_config(url_token, command, text) ⇒ SlashCommandConfig?
98 99 100 101 102 103 |
# File 'lib/slack_bot/config.rb', line 98 def find_slash_command_config(url_token, command, text) endpoint_config = slash_command_endpoints[url_token.to_sym] return if endpoint_config.blank? endpoint_config.find_command_config(text) || endpoint_config end |
#handler_class(class_name, klass) ⇒ void
This method returns an undefined value.
126 127 128 129 130 131 |
# File 'lib/slack_bot/config.rb', line 126 def handler_class(class_name, klass) @handler_classes ||= {} return if class_name.nil? @handler_classes[class_name.to_sym] = klass end |
#interaction(interaction_klass, handler_name: nil) ⇒ void
This method returns an undefined value.
59 60 61 62 |
# File 'lib/slack_bot/config.rb', line 59 def interaction(interaction_klass, handler_name: nil) handler_name ||= interaction_klass.name handler_class(handler_name, interaction_klass) end |
#menu_options(action_id, klass) ⇒ void
This method returns an undefined value.
105 106 107 108 |
# File 'lib/slack_bot/config.rb', line 105 def (action_id, klass) @menu_options ||= {} @menu_options[action_id.to_sym] = klass end |
#slash_command_endpoint(url_token, command_klass = nil, handler_name: nil) {|arg0| ... } ⇒ SlashCommandEndpointConfig
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/slack_bot/config.rb', line 78 def slash_command_endpoint(url_token, command_klass = nil, handler_name: nil, &) @slash_command_endpoints ||= {} @slash_command_endpoints[url_token.to_sym] ||= begin endpoint = SlashCommandEndpointConfig.new( url_token, command_klass: command_klass, config: self, handler_name: handler_name ) endpoint.instance_eval(&) if block_given? endpoint end end |
#slash_command_endpoints ⇒ Hash[Symbol, SlashCommandEndpointConfig]
94 95 96 |
# File 'lib/slack_bot/config.rb', line 94 def slash_command_endpoints @slash_command_endpoints ||= {} end |
#user_session_resolver(method_lambda) ⇒ void
This method returns an undefined value.
42 43 44 |
# File 'lib/slack_bot/config.rb', line 42 def user_session_resolver(method_lambda) @user_session_resolver_method = method_lambda end |
#user_session_resolver! ⇒ Proc
46 47 48 49 50 51 52 |
# File 'lib/slack_bot/config.rb', line 46 def user_session_resolver! return @user_session_resolver_method if @user_session_resolver_method raise SlackBot::Errors::ConfigurationError.new( "user_session_resolver is not configured; call SlackBot::Config.configure { |config| config.user_session_resolver ... }" ) end |