Merge pull request #2637 from johnbellone/patch-1

core: Update Registry with #keys method.
This commit is contained in:
Mitchell Hashimoto 2014-01-10 16:19:53 -08:00
commit fbcc08b3ee
2 changed files with 14 additions and 0 deletions

View File

@ -34,6 +34,13 @@ module Vagrant
def has_key?(key)
@items.has_key?(key)
end
# Returns an array populated with the keys of this object.
#
# @return [Array]
def keys
@items.keys
end
# Iterate over the keyspace.
def each(&block)

View File

@ -40,6 +40,13 @@ describe Vagrant::Registry do
instance["foo"].should eql(object)
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
# Make the proc generate a NEW array each time