Class: Reaction

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Instance Attribute Details

#countInteger (readonly)

Returns the number of users that have reacted with this reaction

Returns:

  • (Integer)

    the number of users that have reacted with this reaction



18
19
20
# File 'src/models/reaction.rb', line 18

def count
  @count
end

#nameString (readonly)

Returns the name of the reaction (without :)

Returns:

  • (String)

    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.

Returns:

  • (Boolean)


38
39
40
# File 'src/models/reaction.rb', line 38

def ==(other)
  @name == other.name && @count == other.count && @user_ids == other.user_ids
end

#usersArray<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.

Returns:

  • (Array<User>)

    The list of users



56
57
58
# File 'src/models/reaction.rb', line 56

def users
  @_users ||= @user_ids.map { |user_id| User.new(@app, user_id) }
end