class Discorb::View::Extension
An extension for using discorb-view. @note Client must extend this class to use discorb-view.
Public Class Methods
inherited(base)
click to toggle source
@private
# File lib/discorb/view/extension.rb, line 16 def self.inherited(base) base.views = {} end
loaded(client)
click to toggle source
# File lib/discorb/view/extension.rb, line 35 def self.loaded(client) class << client attr_accessor :views end client.views = {} end
Public Instance Methods
handle_interaction(interaction)
click to toggle source
@private
# File lib/discorb/view/extension.rb, line 21 def handle_interaction(interaction) unless view = @client.views[interaction.message.id.to_s] @client.log.warn "View: No handler for #{interaction.message.id.to_s}" return end handler = view.class.components[interaction.custom_id.to_sym] @client.log.debug "View: Handling #{interaction.custom_id} in #{interaction.message.id}" view.interaction = interaction update = view.instance_exec(interaction, &handler.block) return unless update @client.log.debug "View: Updating view #{interaction.message.id}" view.render end