模块 IRB::ContextExtender

Context 模块扩展方法

公共类方法

def_extend_command(cmd_name, load_file, *aliases) 点击切换源代码

Context 模块上从给定的 load_file 中评估给定的 command

还会为该方法定义任何给定的 aliases

# File lib/irb/extend-command.rb, line 345
def self.def_extend_command(cmd_name, load_file, *aliases)
  line = __LINE__; Context.module_eval %[
    def #{cmd_name}(*opts, &b)
      Context.module_eval {remove_method(:#{cmd_name})}
      require_relative "#{load_file}"
      __send__ :#{cmd_name}, *opts, &b
    end
    for ali in aliases
      alias_method ali, cmd_name
    end
  ], __FILE__, line
end
install_extend_commands() 点击切换源代码

将默认的上下文扩展安装为 irb 命令

Context#eval_history=

irb/ext/history.rb

Context#use_tracer=

irb/ext/tracer.rb

Context#use_loader=

irb/ext/use-loader.rb

# File lib/irb/extend-command.rb, line 335
def self.install_extend_commands
  for args in @EXTEND_COMMANDS
    def_extend_command(*args)
  end
end