Module: X::Objects::Actions::Relationships

Included in:
X::Objects::API
Defined in:
x-objects/lib/x/objects/actions/relationships.rb

Overview

Follow, block, and mute users as the authenticated user

Internal to x-objects: X::Objects::API includes it, and its methods are public API of the client that includes API, but the module is only how they are grouped, and some of them need the methods of another, so include API rather than this module alone.

Instance Method Summary collapse

Instance Method Details

#block(user) ⇒ Boolean

Block a user as the authenticated user

Examples:

Block a user

client.block("7505382")

Parameters:

  • user (User, String, Integer) —

    the user or their identifier

Returns:

  • (Boolean) —

    true if the authenticated user now blocks the user



50
51
52
# File 'x-objects/lib/x/objects/actions/relationships.rb', line 50

def block(user)
  User.from_id(current_user_id, client: self).block(user)
end

#follow(user) ⇒ Boolean

Follow a user as the authenticated user

A protected user must accept a request to follow them first, so for a protected user true means the follow was requested, not that the authenticated user follows them: until they accept it, the follows? of the authenticated user, as in client.current_user!.follows?(user), answers false.

Examples:

Follow a user

client.follow("7505382")

Parameters:

  • user (User, String, Integer) —

    the user or their identifier

Returns:

  • (Boolean) —

    true if the authenticated user now follows the user, or, for a protected user, has requested to follow them



28
29
30
# File 'x-objects/lib/x/objects/actions/relationships.rb', line 28

def follow(user)
  User.from_id(current_user_id, client: self).follow(user)
end

#mute(user) ⇒ Boolean

Mute a user as the authenticated user

Examples:

Mute a user

client.mute("7505382")

Parameters:

  • user (User, String, Integer) —

    the user or their identifier

Returns:

  • (Boolean) —

    true if the authenticated user now mutes the user



72
73
74
# File 'x-objects/lib/x/objects/actions/relationships.rb', line 72

def mute(user)
  User.from_id(current_user_id, client: self).mute(user)
end

#unblock(user) ⇒ Boolean

Unblock a user as the authenticated user

Examples:

Unblock a user

client.unblock("7505382")

Parameters:

  • user (User, String, Integer) —

    the user or their identifier

Returns:

  • (Boolean) —

    true if the authenticated user no longer blocks the user



61
62
63
# File 'x-objects/lib/x/objects/actions/relationships.rb', line 61

def unblock(user)
  User.from_id(current_user_id, client: self).unblock(user)
end

#unfollow(user) ⇒ Boolean

Unfollow a user as the authenticated user

Examples:

Unfollow a user

client.unfollow("7505382")

Parameters:

  • user (User, String, Integer) —

    the user or their identifier

Returns:

  • (Boolean) —

    true if the authenticated user no longer follows the user



39
40
41
# File 'x-objects/lib/x/objects/actions/relationships.rb', line 39

def unfollow(user)
  User.from_id(current_user_id, client: self).unfollow(user)
end

#unmute(user) ⇒ Boolean

Unmute a user as the authenticated user

Examples:

Unmute a user

client.unmute("7505382")

Parameters:

  • user (User, String, Integer) —

    the user or their identifier

Returns:

  • (Boolean) —

    true if the authenticated user no longer mutes the user



83
84
85
# File 'x-objects/lib/x/objects/actions/relationships.rb', line 83

def unmute(user)
  User.from_id(current_user_id, client: self).unmute(user)
end