Action builder supports indexing middlewares by name
This commit is contained in:
parent
c2649074c3
commit
879f98b5d5
|
@ -101,6 +101,7 @@ module Vagrant
|
||||||
def index(object)
|
def index(object)
|
||||||
stack.each_with_index do |item, i|
|
stack.each_with_index do |item, i|
|
||||||
return i if item[0] == object
|
return i if item[0] == object
|
||||||
|
return i if item[0].respond_to?(:name) && item[0].name == object
|
||||||
end
|
end
|
||||||
|
|
||||||
nil
|
nil
|
||||||
|
|
|
@ -73,6 +73,19 @@ describe Vagrant::Action::Builder do
|
||||||
data[:data].should == [2, 1]
|
data[:data].should == [2, 1]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "can insert by name" do
|
||||||
|
# Create the proc then make sure it has a name
|
||||||
|
bar_proc = appender_proc(2)
|
||||||
|
def bar_proc.name; :bar; end
|
||||||
|
|
||||||
|
instance.use appender_proc(1)
|
||||||
|
instance.use bar_proc
|
||||||
|
instance.insert_before :bar, appender_proc(3)
|
||||||
|
instance.call(data)
|
||||||
|
|
||||||
|
data[:data].should == [1, 3, 2]
|
||||||
|
end
|
||||||
|
|
||||||
it "can insert next to a previous object" do
|
it "can insert next to a previous object" do
|
||||||
proc2 = appender_proc(2)
|
proc2 = appender_proc(2)
|
||||||
instance.use appender_proc(1)
|
instance.use appender_proc(1)
|
||||||
|
|
Loading…
Reference in New Issue