module IRails::History

Public Instance Methods

eval(code, store_history) click to toggle source
Calls superclass method
# File lib/irails/backend.rb, line 6
def eval(code, store_history)
  b = TOPLEVEL_BINDING

  b.local_variable_set(:_ih, In)  unless b.local_variable_defined?(:_ih)
  b.local_variable_set(:_oh, Out) unless b.local_variable_defined?(:_oh)

  out = super

  # TODO Add IRails.cache_size which controls the size of the Out array
  # and sets the oldest entries and _<n> variables to nil.
  if store_history
    b.local_variable_set("_#{Out.size}", out)
    b.local_variable_set("_i#{In.size}", code)

    Out << out
    In << code

    b.local_variable_set(:___,  Out[-3])
    b.local_variable_set(:__,   Out[-2])
    b.local_variable_set(:_,    Out[-1])
    b.local_variable_set(:_iii, In[-3])
    b.local_variable_set(:_ii,  In[-2])
    b.local_variable_set(:_i,   In[-1])
  end

  out
end