зеркало из https://github.com/github/ruby.git
[ruby/reline] Change Reline.add_dialog_proc(name, nil) to properly
remove dialog_proc (https://github.com/ruby/reline/pull/532) https://github.com/ruby/reline/commit/43283b2f37
This commit is contained in:
Родитель
34f484d233
Коммит
19aa30d5d5
|
@ -166,9 +166,13 @@ module Reline
|
|||
|
||||
DialogProc = Struct.new(:dialog_proc, :context)
|
||||
def add_dialog_proc(name_sym, p, context = nil)
|
||||
raise ArgumentError unless p.respond_to?(:call) or p.nil?
|
||||
raise ArgumentError unless name_sym.instance_of?(Symbol)
|
||||
@dialog_proc_list[name_sym] = DialogProc.new(p, context)
|
||||
if p.nil?
|
||||
@dialog_proc_list.delete(name_sym)
|
||||
else
|
||||
raise ArgumentError unless p.respond_to?(:call)
|
||||
@dialog_proc_list[name_sym] = DialogProc.new(p, context)
|
||||
end
|
||||
end
|
||||
|
||||
def dialog_proc(name_sym)
|
||||
|
|
|
@ -321,6 +321,9 @@ class Reline::Test < Reline::TestCase
|
|||
d = Reline.dialog_proc(:test_proc)
|
||||
assert_equal(dummy_proc_2, d.dialog_proc)
|
||||
|
||||
Reline.add_dialog_proc(:test_proc, nil)
|
||||
assert_nil(Reline.dialog_proc(:test_proc))
|
||||
|
||||
l = lambda {}
|
||||
Reline.add_dialog_proc(:test_lambda, l)
|
||||
d = Reline.dialog_proc(:test_lambda)
|
||||
|
|
Загрузка…
Ссылка в новой задаче