Class: Slackify::Handlers::Base
- Inherits:
-
Object
- Object
- Slackify::Handlers::Base
- Defined in:
- lib/slackify/handlers/base.rb
Overview
Base handler class that any user defined handlers must inherit from
Direct Known Subclasses
Constant Summary collapse
- @@supported_handlers =
[]
Class Attribute Summary collapse
-
.allowed_slash_methods ⇒ Object
readonly
Returns the value of attribute allowed_slash_methods.
Class Method Summary collapse
-
.allow_slash_method(element) ⇒ Object
Enables a method to be called for a slash command.
-
.inherited(subclass) ⇒ Object
Any class inheriting from Slackify::Handler::Base will be added to the list of supported handlers.
-
.slack_client ⇒ Object
Get the slack client that you can use to perform slack api calls.
-
.supported_handlers ⇒ Object
Show a list of the handlers supported by the app.
Class Attribute Details
.allowed_slash_methods ⇒ Object (readonly)
Returns the value of attribute allowed_slash_methods.
10 11 12 |
# File 'lib/slackify/handlers/base.rb', line 10 def allowed_slash_methods @allowed_slash_methods end |
Class Method Details
.allow_slash_method(element) ⇒ Object
Enables a method to be called for a slash command.
More context: Slash commands have extra validations. To call a slash command, it needs to call a method on a supported handler and that handler needs to explicitly specify which methods are for slash command.
24 25 26 27 28 29 30 |
# File 'lib/slackify/handlers/base.rb', line 24 def allow_slash_method(element) if defined?(@allowed_slash_methods) && @allowed_slash_methods @allowed_slash_methods.push(*element) else @allowed_slash_methods = Array(element) end end |
.inherited(subclass) ⇒ Object
Any class inheriting from Slackify::Handler::Base will be added to the list of supported handlers
34 35 36 37 |
# File 'lib/slackify/handlers/base.rb', line 34 def inherited(subclass) super @@supported_handlers.push(subclass.to_s) end |
.slack_client ⇒ Object
Get the slack client that you can use to perform slack api calls
14 15 16 |
# File 'lib/slackify/handlers/base.rb', line 14 def slack_client Slackify.configuration.slack_client end |
.supported_handlers ⇒ Object
Show a list of the handlers supported by the app. Since we do metaprogramming, we want to ensure we can only call defined handlers
41 42 43 |
# File 'lib/slackify/handlers/base.rb', line 41 def supported_handlers @@supported_handlers end |