Module: IRB::ContextExtender

Defined in:
lib/irb/extend-command.rb

Overview

Extends methods for the Context module

Constant Summary collapse

CE =

:nodoc:

ContextExtender

Class Method Summary collapse

Class Method Details

.def_extend_command(cmd_name, load_file, *aliases) ⇒ Object

Evaluate the given command from the given load_file on the Context module.

Will also define any given aliases for the method.



287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/irb/extend-command.rb', line 287

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 "#{load_file}"
      __send__ :#{cmd_name}, *opts, &b
    end
    for ali in aliases
      alias_method ali, cmd_name
    end
  ], __FILE__, line
end

.install_extend_commandsObject

Installs the default context extensions as irb commands:

Context#eval_history=

irb/ext/history.rb

Context#use_tracer=

irb/ext/tracer.rb

Context#use_loader=

irb/ext/use-loader.rb

Context#save_history=

irb/ext/save-history.rb



277
278
279
280
281
# File 'lib/irb/extend-command.rb', line 277

def self.install_extend_commands
  for args in @EXTEND_COMMANDS
    def_extend_command(*args)
  end
end