class Discorb::AuditLog::Entry::Change

Represents a change in an audit log entry. @note This instance will try to call a method of {#new_value} if the method wasn't defined.

Attributes

key[R]

@return [Symbol] The key of the change.

new_value[R]

@return [Object] The new value of the change.

old_value[R]

@return [Object] The old value of the change.

Public Class Methods

new(data) click to toggle source

@!visibility private

# File lib/discorb/audit_logs.rb, line 268
def initialize(data)
  @key = data[:key].to_sym
  method = case @key.to_s
           when /.*_id$/, 'id'
             ->(v) { Snowflake.new(v) }
           when 'permissions'
             ->(v) { Discorb::Permission.new(v.to_i) }
           else
             ->(v) { v }
           end
  @old_value = data[:old_value].then(&method)
  @new_value = data[:new_value].then(&method)
end

Public Instance Methods

inspect() click to toggle source
# File lib/discorb/audit_logs.rb, line 289
def inspect
  "#<#{self.class} #{@key.inspect} #{@old_value.inspect} -> #{@new_value.inspect}>"
end
method_missing(method, ...) click to toggle source

Send a message to the new value.

# File lib/discorb/audit_logs.rb, line 285
def method_missing(method, ...)
  @new_value.__send__(method, ...)
end
respond_to_missing?(method, include_private = false) click to toggle source
# File lib/discorb/audit_logs.rb, line 293
def respond_to_missing?(method, include_private = false)
  @new_value.respond_to?(method, include_private)
end