Class: Waylon::Sense
- Inherits:
-
Object
- Object
- Waylon::Sense
- Includes:
- BaseComponent
- Defined in:
- lib/waylon/sense.rb
Overview
Base class for Senses (Usually messaging providers like Slack)
Direct Known Subclasses
Class Method Summary collapse
-
.codify(text) ⇒ String
Almost always meant to be overridden, this is how the Sense wraps text in a code block.
-
.config_namespace ⇒ String
Config namespace for config keys.
-
.enqueue(route, request) ⇒ Object
private
The connection between Senses and Skills happens here, via a Route and a Hash of details.
-
.group_class ⇒ Class
Provides a simple mechanism for referencing the Group subclass provided by this Sense.
-
.mention(user) ⇒ String
“At-mention” a User via the Sense.
-
.message_class ⇒ Class
Provides a simple mechanism for referencing the Message subclass provided by this Sense.
-
.perform(content) ⇒ Object
Called by Resque to actually use this BaseComponent.
-
.queue ⇒ Symbol
private
Redis/Resque queue name.
-
.user_class ⇒ Class
Provides a simple mechanism for referencing the User subclass provided by this Sense.
Methods included from BaseComponent
Class Method Details
.codify(text) ⇒ String
Almost always meant to be overridden, this is how the Sense wraps text in a code block
11 12 13 |
# File 'lib/waylon/sense.rb', line 11 def self.codify(text) "```\n#{text}```" end |
.config_namespace ⇒ String
Config namespace for config keys
17 18 19 |
# File 'lib/waylon/sense.rb', line 17 def self.config_namespace "senses.#{component_namespace}" end |
.enqueue(route, request) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The connection between Senses and Skills happens here, via a Route and a Hash of details
25 26 27 28 29 30 31 32 33 |
# File 'lib/waylon/sense.rb', line 25 def self.enqueue(route, request) details = { "sense" => self, "request" => request, "route" => route.name } Resque.enqueue route.destination, details end |
.group_class ⇒ Class
Provides a simple mechanism for referencing the Group subclass provided by this Sense
37 38 39 |
# File 'lib/waylon/sense.rb', line 37 def self.group_class Group end |
.mention(user) ⇒ String
“At-mention” a User via the Sense. This is usually overridden on Sense subclasses.
44 45 46 |
# File 'lib/waylon/sense.rb', line 44 def self.mention(user) "@#{user.handle}" end |
.message_class ⇒ Class
Provides a simple mechanism for referencing the Message subclass provided by this Sense
50 51 52 |
# File 'lib/waylon/sense.rb', line 50 def self. Message end |
.perform(content) ⇒ Object
Called by Resque to actually use this BaseComponent. Hands off to run() method
56 57 58 |
# File 'lib/waylon/sense.rb', line 56 def self.perform(content) run(content) end |
.queue ⇒ Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Redis/Resque queue name
63 64 65 |
# File 'lib/waylon/sense.rb', line 63 def self.queue :senses end |
.user_class ⇒ Class
Provides a simple mechanism for referencing the User subclass provided by this Sense
69 70 71 |
# File 'lib/waylon/sense.rb', line 69 def self.user_class User end |