Module: Console1984::Ext::Irb::Context

Includes:
Freezeable
Defined in:
lib/console1984/ext/irb/context.rb

Overview

Extends IRB execution contexts to hijack execution attempts and pass them through Console1984.

Instance Method Summary collapse

Methods included from Freezeable

freeze_all, included

Instance Method Details

#evaluate(line_or_statement) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/console1984/ext/irb/context.rb', line 15

def evaluate(line_or_statement, ...)
  # irb  < 1.13 passes String as parameter
  # irb >= 1.13 passes IRB::Statement instead and method #code contains the actual code
  code = if defined?(IRB::Statement) && line_or_statement.kind_of?(IRB::Statement)
    line_or_statement.code
  else
    line_or_statement
  end

  Console1984.command_executor.execute(Array(code)) do
    super
  end
end

#inspect_last_valueObject

This method is invoked for showing returned objects in the console Overridden to make sure their evaluation is supervised.



8
9
10
11
12
# File 'lib/console1984/ext/irb/context.rb', line 8

def inspect_last_value
  Console1984.command_executor.execute_in_protected_mode do
    super
  end
end