Class: Reaction
- Inherits:
-
Object
- Object
- Reaction
- Defined in:
- src/models/reaction.rb
Overview
Describes reactions on a message
This does not represent a single reaction by a single user, rather a reaction that may be used by multiple users.
The users array might not always contain all users that have reacted
(Slack limits it to X users, and X might change), however count
always represents the count of all users who made that reaction
(i.e. it may be greater than users.length
).
If the authenticated user has a given reaction then they are guaranteed to
appear in the users array, regardless of whether count is greater than
users.length
or not.
Instance Attribute Summary collapse
-
#count ⇒ Integer
readonly
The number of users that have reacted with this reaction.
-
#name ⇒ String
readonly
The name of the reaction (without
:
).
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
(also: #eql)
Compare two reactions by name, count and user_ids.
-
#users ⇒ Array<User>
Get a possibly non-exhaustive list of users that have reacted on this message.
Instance Attribute Details
#count ⇒ Integer (readonly)
Returns the number of users that have reacted with this reaction
18 19 20 |
# File 'src/models/reaction.rb', line 18 def count @count end |
#name ⇒ String (readonly)
Returns the name of the reaction (without :
)
15 16 17 |
# File 'src/models/reaction.rb', line 15 def name @name end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql
Compare two reactions by name, count and user_ids
Not a terribly useful method, but still has applications in tests.
38 39 40 |
# File 'src/models/reaction.rb', line 38 def ==(other) @name == other.name && @count == other.count && @user_ids == other.user_ids end |
#users ⇒ Array<User>
Get a possibly non-exhaustive list of users that have reacted on this message
See the description on Reaction for additional information.
This method caches its result. To reload the data, call Message#reactions again.
56 57 58 |
# File 'src/models/reaction.rb', line 56 def users @_users ||= @user_ids.map { |user_id| User.new(@app, user_id) } end |