Class: SlackBot::SlashCommandConfig
- Inherits:
-
Object
- Object
- SlackBot::SlashCommandConfig
- Defined in:
- lib/slack_bot/config.rb,
sig/slack_bot.rbs
Instance Attribute Summary collapse
-
#command_klass ⇒ Class
Returns the value of attribute command_klass.
-
#endpoint ⇒ SlashCommandEndpointConfig
Returns the value of attribute endpoint.
-
#parent_configs ⇒ Array[SlashCommandConfig]
Returns the value of attribute parent_configs.
-
#token ⇒ Symbol
Returns the value of attribute token.
Class Method Summary collapse
Instance Method Summary collapse
- #argument_command(argument_token, klass = nil) {|arg0| ... } ⇒ SlashCommandConfig
- #find_argument_command_config(argument_token) ⇒ SlashCommandConfig?
- #full_token ⇒ String
-
#initialize(command_klass:, token:, endpoint:, parent_configs: [], handler_name: nil) ⇒ SlashCommandConfig
constructor
A new instance of SlashCommandConfig.
- #url_token ⇒ Symbol
Constructor Details
#initialize(command_klass:, token:, endpoint:, parent_configs: [], handler_name: nil) ⇒ SlashCommandConfig
Returns a new instance of SlashCommandConfig.
198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/slack_bot/config.rb', line 198 def initialize(command_klass:, token:, endpoint:, parent_configs: [], handler_name: nil) @command_klass = command_klass @token = token @parent_configs = parent_configs || [] @endpoint = endpoint endpoint.routes[full_token] = self handler_name ||= command_klass.name endpoint.config.handler_class(handler_name, command_klass) end |
Instance Attribute Details
#command_klass ⇒ Class
Returns the value of attribute command_klass.
197 198 199 |
# File 'lib/slack_bot/config.rb', line 197 def command_klass @command_klass end |
#endpoint ⇒ SlashCommandEndpointConfig
Returns the value of attribute endpoint.
197 198 199 |
# File 'lib/slack_bot/config.rb', line 197 def endpoint @endpoint end |
#parent_configs ⇒ Array[SlashCommandConfig]
Returns the value of attribute parent_configs.
197 198 199 |
# File 'lib/slack_bot/config.rb', line 197 def parent_configs @parent_configs end |
#token ⇒ Symbol
Returns the value of attribute token.
197 198 199 |
# File 'lib/slack_bot/config.rb', line 197 def token @token end |
Class Method Details
.delimiter ⇒ String
193 194 195 |
# File 'lib/slack_bot/config.rb', line 193 def self.delimiter " " end |
Instance Method Details
#argument_command(argument_token, klass = nil) {|arg0| ... } ⇒ SlashCommandConfig
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/slack_bot/config.rb', line 210 def argument_command(argument_token, klass = nil, &) @argument_command_configs ||= {} @argument_command_configs[argument_token.to_sym] ||= SlashCommandConfig.new( command_klass: command_klass, token: argument_token, parent_configs: [self] + (parent_configs || []), endpoint: endpoint ) command_config = @argument_command_configs[argument_token.to_sym] command_config.instance_eval(&) if block_given? command_config end |
#find_argument_command_config(argument_token) ⇒ SlashCommandConfig?
226 227 228 229 |
# File 'lib/slack_bot/config.rb', line 226 def find_argument_command_config(argument_token) @argument_command_configs ||= {} @argument_command_configs[argument_token.to_sym] end |
#full_token ⇒ String
231 232 233 234 235 |
# File 'lib/slack_bot/config.rb', line 231 def full_token [parent_configs.map(&:token), token].flatten.compact.join( self.class.delimiter ) end |
#url_token ⇒ Symbol
237 238 239 |
# File 'lib/slack_bot/config.rb', line 237 def url_token endpoint.url_token end |