Class: SlackBot::SlashCommandConfig
- Inherits:
-
Object
- Object
- SlackBot::SlashCommandConfig
- Defined in:
- lib/slack_bot/config.rb
Instance Attribute Summary collapse
-
#command_klass ⇒ Object
Returns the value of attribute command_klass.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#parent_configs ⇒ Object
Returns the value of attribute parent_configs.
-
#token ⇒ Object
Returns the value of attribute token.
Class Method Summary collapse
Instance Method Summary collapse
- #argument_command(argument_token, klass = nil) ⇒ Object
- #find_argument_command_config(argument_token) ⇒ Object
- #full_token ⇒ Object
-
#initialize(command_klass:, token:, endpoint:, parent_configs: [], handler_name: nil) ⇒ SlashCommandConfig
constructor
A new instance of SlashCommandConfig.
- #url_token ⇒ Object
Constructor Details
#initialize(command_klass:, token:, endpoint:, parent_configs: [], handler_name: nil) ⇒ SlashCommandConfig
Returns a new instance of SlashCommandConfig.
146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/slack_bot/config.rb', line 146 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 ⇒ Object
Returns the value of attribute command_klass.
145 146 147 |
# File 'lib/slack_bot/config.rb', line 145 def command_klass @command_klass end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
145 146 147 |
# File 'lib/slack_bot/config.rb', line 145 def endpoint @endpoint end |
#parent_configs ⇒ Object
Returns the value of attribute parent_configs.
145 146 147 |
# File 'lib/slack_bot/config.rb', line 145 def parent_configs @parent_configs end |
#token ⇒ Object
Returns the value of attribute token.
145 146 147 |
# File 'lib/slack_bot/config.rb', line 145 def token @token end |
Class Method Details
.delimiter ⇒ Object
141 142 143 |
# File 'lib/slack_bot/config.rb', line 141 def self.delimiter " " end |
Instance Method Details
#argument_command(argument_token, klass = nil) ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/slack_bot/config.rb', line 158 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) ⇒ Object
174 175 176 177 |
# File 'lib/slack_bot/config.rb', line 174 def find_argument_command_config(argument_token) @argument_command_configs ||= {} @argument_command_configs[argument_token.to_sym] end |
#full_token ⇒ Object
179 180 181 182 183 |
# File 'lib/slack_bot/config.rb', line 179 def full_token [parent_configs.map(&:token), token].flatten.compact.join( self.class.delimiter ) end |
#url_token ⇒ Object
185 186 187 |
# File 'lib/slack_bot/config.rb', line 185 def url_token endpoint.url_token end |