Class: SlackInteractiveClient::BaseInteraction
- Inherits:
-
Object
- Object
- SlackInteractiveClient::BaseInteraction
- Includes:
- SlackInteractionParams, SlackPatternInteraction
- Defined in:
- lib/slack_interactive_client/base_interaction.rb
Direct Known Subclasses
Constant Summary
Constants included from SlackInteractionParams
SlackInteractionParams::DIRECT_MESSAGE_CHANNEL
Class Attribute Summary collapse
-
.interaction_channels ⇒ Object
readonly
Returns the value of attribute interaction_channels.
-
.interaction_config ⇒ Object
readonly
Returns the value of attribute interaction_config.
-
.pattern_string ⇒ Object
readonly
Returns the value of attribute pattern_string.
Instance Attribute Summary collapse
-
#interaction_params ⇒ Object
readonly
Returns the value of attribute interaction_params.
Class Method Summary collapse
-
.interaction_options(options = {}) ⇒ Object
EXAMPLE.
- .interaction_pattern(pattern_string = '') ⇒ Object
Instance Method Summary collapse
- #call ⇒ Object
- #execute ⇒ Object
-
#initialize(webhook_params = {}) ⇒ BaseInteraction
constructor
A new instance of BaseInteraction.
Methods included from SlackPatternInteraction
#method_missing, #respond_to_missing?
Methods included from SlackInteractionParams
#slack_channel_id, #slack_channel_name, #slack_command, #slack_message_text, #slack_response_url, #slack_team_domain, #slack_team_id, #slack_token, #slack_user_id, #slack_user_name
Constructor Details
#initialize(webhook_params = {}) ⇒ BaseInteraction
Returns a new instance of BaseInteraction.
50 51 52 53 54 55 |
# File 'lib/slack_interactive_client/base_interaction.rb', line 50 def initialize(webhook_params = {}) @interaction_params = webhook_params @pattern = self.class.pattern_string @extracted_values = {} extract_values() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class SlackPatternInteraction
Class Attribute Details
.interaction_channels ⇒ Object (readonly)
Returns the value of attribute interaction_channels.
14 15 16 |
# File 'lib/slack_interactive_client/base_interaction.rb', line 14 def interaction_channels @interaction_channels end |
.interaction_config ⇒ Object (readonly)
Returns the value of attribute interaction_config.
14 15 16 |
# File 'lib/slack_interactive_client/base_interaction.rb', line 14 def interaction_config @interaction_config end |
.pattern_string ⇒ Object (readonly)
Returns the value of attribute pattern_string.
14 15 16 |
# File 'lib/slack_interactive_client/base_interaction.rb', line 14 def pattern_string @pattern_string end |
Instance Attribute Details
#interaction_params ⇒ Object (readonly)
Returns the value of attribute interaction_params.
49 50 51 |
# File 'lib/slack_interactive_client/base_interaction.rb', line 49 def interaction_params @interaction_params end |
Class Method Details
.interaction_options(options = {}) ⇒ Object
EXAMPLE
interaction_options can_interact: { only: [‘micah.bowie’] }, channels: []
19 20 21 22 |
# File 'lib/slack_interactive_client/base_interaction.rb', line 19 def ( = {}) set_interaction_config([:can_interact]) @interaction_channels = [:channels].empty? ? :all : [:channels] end |
.interaction_pattern(pattern_string = '') ⇒ Object
24 25 26 |
# File 'lib/slack_interactive_client/base_interaction.rb', line 24 def interaction_pattern(pattern_string = '') @pattern_string = pattern_string.strip.squeeze end |
Instance Method Details
#call ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/slack_interactive_client/base_interaction.rb', line 57 def call unless can_interact? ('You are not authorized to interact with this command or interaction is in an invalid channel.') return end execute end |
#execute ⇒ Object
65 66 67 |
# File 'lib/slack_interactive_client/base_interaction.rb', line 65 def execute puts "Method not reimplemented by child" end |