class MijDiscord::Data::Overwrite
Attributes
allow[RW]
deny[RW]
type[RW]
Public Class Methods
from_hash(data)
click to toggle source
# File lib/mij-discord/data/permissions.rb, line 120 def self.from_hash(data) Overwrite.new( data['id'].to_i, type: data['type'].to_sym, allow: Permissions.new(data['allow']), deny: Permissions.new(data['deny']) ) end
new(object, type: nil, allow: 0, deny: 0)
click to toggle source
# File lib/mij-discord/data/permissions.rb, line 97 def initialize(object, type: nil, allow: 0, deny: 0) case type when nil, :member, :role # Do nothing else raise ArgumentError, 'Overwrite type must be :member or :role' end @id = object.to_id @type = case object when User, Member, Recipient, Profile :member when Role :role else type end @allow = allow.is_a?(Permissions) ? allow : Permissions.new(allow) @deny = deny.is_a?(Permissions) ? deny : Permissions.new(deny) end
Public Instance Methods
inspect()
click to toggle source
# File lib/mij-discord/data/permissions.rb, line 133 def inspect MijDiscord.make_inspect(self, :id, :type, :allow, :deny) end
to_hash()
click to toggle source
# File lib/mij-discord/data/permissions.rb, line 129 def to_hash { id: @id, type: @type, allow: @allow.bits, deny: @deny.bits } end