Skip to content

Commit 212e8b7

Browse files
authored
Refactor ExtendCommand::Nop (#598)
* Rename conf to irb_context * Drop Nop#irb method because it's only used by irb/ext/loader.rb We don't need to expose this method to all command classes, especially when it's just an alias of `irb_context.irb`.
1 parent 0a0409c commit 212e8b7

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

lib/irb/cmd/nop.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,19 @@ def string_literal?(args)
3030
end
3131
end
3232

33-
def self.execute(conf, *opts, **kwargs, &block)
34-
command = new(conf)
33+
def self.execute(irb_context, *opts, **kwargs, &block)
34+
command = new(irb_context)
3535
command.execute(*opts, **kwargs, &block)
3636
rescue CommandArgumentError => e
3737
puts e.message
3838
end
3939

40-
def initialize(conf)
41-
@irb_context = conf
40+
def initialize(irb_context)
41+
@irb_context = irb_context
4242
end
4343

4444
attr_reader :irb_context
4545

46-
def irb
47-
@irb_context.irb
48-
end
49-
5046
def execute(*opts)
5147
#nop
5248
end

lib/irb/ext/loader.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def search_file_from_ruby_path(fn) # :nodoc:
4242
#
4343
# See Irb#suspend_input_method for more information.
4444
def source_file(path)
45+
irb = irb_context.irb
4546
irb.suspend_name(path, File.basename(path)) do
4647
FileInputMethod.open(path) do |io|
4748
irb.suspend_input_method(io) do
@@ -66,6 +67,7 @@ def source_file(path)
6667
#
6768
# See Irb#suspend_input_method for more information.
6869
def load_file(path, priv = nil)
70+
irb = irb_context.irb
6971
irb.suspend_name(path, File.basename(path)) do
7072

7173
if priv

0 commit comments

Comments
 (0)