module Console1984::Ext::Core::Module
Extends Module
to prevent invoking class_eval in user commands.
We don't use the built-in configurable system from protections.yml because we use class_eval ourselves to implement it!
Public Instance Methods
instance_eval(*)
click to toggle source
Calls superclass method
# File lib/console1984/ext/core/module.rb, line 8 def instance_eval(*) if Console1984.command_executor.executing_user_command? raise Console1984::Errors::ForbiddenCommandAttempted else super end end
method_added(method)
click to toggle source
# File lib/console1984/ext/core/module.rb, line 16 def method_added(method) if Console1984.command_executor.from_irb?(caller) && banned_for_reopening? raise Console1984::Errors::ForbiddenCommandExecuted, "Trying to add method `#{method}` to #{self.name}" end end
Private Instance Methods
banned_for_reopening?()
click to toggle source
# File lib/console1984/ext/core/module.rb, line 23 def banned_for_reopening? classes_and_modules_banned_for_reopening.find do |banned_class_or_module_name| "#{self.name}::".start_with?("#{banned_class_or_module_name}::") end end
classes_and_modules_banned_for_reopening()
click to toggle source
# File lib/console1984/ext/core/module.rb, line 29 def classes_and_modules_banned_for_reopening @classes_and_modules_banned_for_reopening ||= Console1984.protections_config.validations[:forbidden_reopening] end