Merge pull request #2637 from johnbellone/patch-1
core: Update Registry with #keys method.
This commit is contained in:
commit
fbcc08b3ee
|
@ -35,6 +35,13 @@ module Vagrant
|
||||||
@items.has_key?(key)
|
@items.has_key?(key)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns an array populated with the keys of this object.
|
||||||
|
#
|
||||||
|
# @return [Array]
|
||||||
|
def keys
|
||||||
|
@items.keys
|
||||||
|
end
|
||||||
|
|
||||||
# Iterate over the keyspace.
|
# Iterate over the keyspace.
|
||||||
def each(&block)
|
def each(&block)
|
||||||
@items.each do |key, _|
|
@items.each do |key, _|
|
||||||
|
|
|
@ -41,6 +41,13 @@ describe Vagrant::Registry do
|
||||||
instance["foo"].should eql(object)
|
instance["foo"].should eql(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should be able to get keys with #keys" do
|
||||||
|
instance.register("foo") { "bar" }
|
||||||
|
instance.register("baz") { "qux" }
|
||||||
|
|
||||||
|
instance.keys.sort.should == [ 'baz', 'foo' ]
|
||||||
|
end
|
||||||
|
|
||||||
it "should cache the result of the item so they can be modified" do
|
it "should cache the result of the item so they can be modified" do
|
||||||
# Make the proc generate a NEW array each time
|
# Make the proc generate a NEW array each time
|
||||||
instance.register("foo") { [] }
|
instance.register("foo") { [] }
|
||||||
|
|
Loading…
Reference in New Issue