Class: OnyxCord::Interactions::PermissionBuilder Deprecated
- Inherits:
-
Object
- Object
- OnyxCord::Interactions::PermissionBuilder
- Defined in:
- lib/onyxcord/interactions/internal/permission_builder.rb
Overview
Deprecated.
This system is being replaced in the near future.
Builder for creating server application command permissions.
Constant Summary collapse
- ROLE =
Role permission type
1- USER =
User permission type
2
Instance Method Summary collapse
-
#allow(object) ⇒ PermissionBuilder
Allow an entity to use this command.
-
#allow_role(role_id) ⇒ PermissionBuilder
Allow a role to use this command.
-
#allow_user(user_id) ⇒ PermissionBuilder
Allow a user to use this command.
-
#deny(object) ⇒ PermissionBuilder
Deny an entity usage of this command.
-
#deny_role(role_id) ⇒ PermissionBuilder
Deny a role usage of this command.
-
#deny_user(user_id) ⇒ PermissionBuilder
Deny a user usage of this command.
-
#initialize ⇒ PermissionBuilder
constructor
A new instance of PermissionBuilder.
Constructor Details
#initialize ⇒ PermissionBuilder
Returns a new instance of PermissionBuilder.
14 15 16 |
# File 'lib/onyxcord/interactions/internal/permission_builder.rb', line 14 def initialize @permissions = [] end |
Instance Method Details
#allow(object) ⇒ PermissionBuilder
Allow an entity to use this command.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/onyxcord/interactions/internal/permission_builder.rb', line 50 def allow(object) case object when OnyxCord::User, OnyxCord::Member create_entry(object.id, USER, true) when OnyxCord::Role create_entry(object.id, ROLE, true) else raise ArgumentError, "Unable to create permission for unknown type: #{object.class}" end end |
#allow_role(role_id) ⇒ PermissionBuilder
Allow a role to use this command.
21 22 23 |
# File 'lib/onyxcord/interactions/internal/permission_builder.rb', line 21 def allow_role(role_id) create_entry(role_id, ROLE, true) end |
#allow_user(user_id) ⇒ PermissionBuilder
Allow a user to use this command.
35 36 37 |
# File 'lib/onyxcord/interactions/internal/permission_builder.rb', line 35 def allow_user(user_id) create_entry(user_id, USER, true) end |
#deny(object) ⇒ PermissionBuilder
Deny an entity usage of this command.
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/onyxcord/interactions/internal/permission_builder.rb', line 65 def deny(object) case object when OnyxCord::User, OnyxCord::Member create_entry(object.id, USER, false) when OnyxCord::Role create_entry(object.id, ROLE, false) else raise ArgumentError, "Unable to create permission for unknown type: #{object.class}" end end |
#deny_role(role_id) ⇒ PermissionBuilder
Deny a role usage of this command.
28 29 30 |
# File 'lib/onyxcord/interactions/internal/permission_builder.rb', line 28 def deny_role(role_id) create_entry(role_id, ROLE, false) end |
#deny_user(user_id) ⇒ PermissionBuilder
Deny a user usage of this command.
42 43 44 |
# File 'lib/onyxcord/interactions/internal/permission_builder.rb', line 42 def deny_user(user_id) create_entry(user_id, USER, false) end |