Through a RubyLex instance's lifetime, the context passed to its methods should be the same. Given that Context is only initialised in Irb#initialize, this should be true.
When RubyLex is initialised, the context object should be accessible. This is also true in all 3 of RubyLex.new's invocations.
With the above observations, we should be able to store the context in RubyLex as an instance variable. And doing so will make RubyLex's instance methods easier to use and maintain.
[ruby/irb] Store context in RubyLex
Some background for this refactor:
Through a RubyLex instance's lifetime, the context passed to its methods
should be the same.
Given that
Contextis only initialised inIrb#initialize,this should be true.
When
RubyLexis initialised, the context object should be accessible.This is also true in all 3 of
RubyLex.new's invocations.With the above observations, we should be able to store the context in
RubyLexas an instance variable. And doing so will make
RubyLex's instance methodseasier to use and maintain.
https://github.com/ruby/irb/commit/5c8d3df2df