Class: Discordrb::Overwrite
- Inherits:
-
Object
- Object
- Discordrb::Overwrite
- Defined in:
- lib/discordrb/data.rb
Overview
A permissions overwrite, when applied to channels describes additional permissions a member needs to perform certain actions in context.
Instance Attribute Summary collapse
-
#allow ⇒ Permissions
Allowed permissions for this overwrite type.
-
#deny ⇒ Permissions
Denied permissions for this overwrite type.
-
#id ⇒ Integer
Id of the thing associated with this overwrite type.
-
#type ⇒ Symbol
Either :role or :member.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Comparison by attributes [:id, :type, :allow, :deny].
-
#initialize(object = nil, type: nil, allow: 0, deny: 0) ⇒ Overwrite
constructor
Creates a new Overwrite object.
Constructor Details
#initialize(object = nil, type: nil, allow: 0, deny: 0) ⇒ Overwrite
Creates a new Overwrite object
1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 |
# File 'lib/discordrb/data.rb', line 1237 def initialize(object = nil, type: nil, allow: 0, deny: 0) if type type = type.to_sym raise ArgumentError, 'Overwrite type must be :member or :role' unless (type != :member) || (type != :role) end @id = object.respond_to?(:id) ? object.id : object @type = if object.is_a?(User) || object.is_a?(Member) || object.is_a?(Recipient) || object.is_a?(Profile) :member elsif object.is_a? Role :role else type end @allow = allow.is_a?(Permissions) ? allow : Permissions.new(allow) @deny = deny.is_a?(Permissions) ? deny : Permissions.new(deny) end |
Instance Attribute Details
#allow ⇒ Permissions
Returns allowed permissions for this overwrite type.
1212 1213 1214 |
# File 'lib/discordrb/data.rb', line 1212 def allow @allow end |
#deny ⇒ Permissions
Returns denied permissions for this overwrite type.
1215 1216 1217 |
# File 'lib/discordrb/data.rb', line 1215 def deny @deny end |
#id ⇒ Integer
Returns id of the thing associated with this overwrite type.
1206 1207 1208 |
# File 'lib/discordrb/data.rb', line 1206 def id @id end |
#type ⇒ Symbol
Returns either :role or :member.
1209 1210 1211 |
# File 'lib/discordrb/data.rb', line 1209 def type @type end |