Class: Appwrite::Role

Inherits:
Object
  • Object
show all
Defined in:
lib/appwrite/role.rb

Overview

Helper class to generate role strings for Permission.

Class Method Summary collapse

Class Method Details

.any ⇒ String

Grants access to anyone.

This includes authenticated and unauthenticated users.

Returns:

  • (String)


9
10
11
# File 'lib/appwrite/role.rb', line 9

def self.any
    'any'
end

.guests ⇒ String

Grants access to any guest user without a session.

Authenticated users don't have access to this role.

Returns:

  • (String)


51
52
53
# File 'lib/appwrite/role.rb', line 51

def self.guests
    'guests'
end

.label(name) ⇒ String

Grants access to a user with the specified label.

Parameters:

  • name (String)

Returns:

  • (String)


89
90
91
# File 'lib/appwrite/role.rb', line 89

def self.label(name)
    "label:#{name}"
end

.member(id) ⇒ String

Grants access to a specific member of a team.

When the member is removed from the team, they will no longer have access.

Parameters:

  • id (String)

Returns:

  • (String)


80
81
82
# File 'lib/appwrite/role.rb', line 80

def self.member(id)
    "member:#{id}"
end

.team(id, role = "") ⇒ String

Grants access to a team by team ID.

You can optionally pass a role for role to target team members with the specified role.

Parameters:

  • id (String)
  • role (String) (defaults to: "")

Returns:

  • (String)


64
65
66
67
68
69
70
# File 'lib/appwrite/role.rb', line 64

def self.team(id, role = "")
    if (role.empty?)
        "team:#{id}"
    else
        "team:#{id}/#{role}"
    end
end

.user(id, status = "") ⇒ String

Grants access to a specific user by user ID.

You can optionally pass verified or unverified for status to target specific types of users.

Parameters:

  • id (String)
  • status (String) (defaults to: "")

Returns:

  • (String)


22
23
24
25
26
27
28
# File 'lib/appwrite/role.rb', line 22

def self.user(id, status = "")
    if (status.empty?)
        "user:#{id}"
    else
        "user:#{id}/#{status}"
    end
end

.users(status = "") ⇒ String

Grants access to any authenticated or anonymous user.

You can optionally pass verified or unverified for status to target specific types of users.

Parameters:

  • status (String) (defaults to: "")

Returns:

  • (String)


38
39
40
41
42
43
44
# File 'lib/appwrite/role.rb', line 38

def self.users(status = "")
    if (status.empty?)
        'users'
    else
        "users/#{status}"
    end
end