Make Registry enumerable

Registry already responds to #each, so including the Enumerable module
gives us nice methods like #select and #collect fo' free!
This commit is contained in:
Seth Vargo 2014-10-23 11:23:55 -04:00
parent bc4bbb9fc0
commit 2b03838fba
2 changed files with 6 additions and 0 deletions

View File

@ -4,6 +4,8 @@ module Vagrant
# This allows certain components (such as guest systems, configuration
# pieces, etc.) to be registered and queried, lazily.
class Registry
include Enumerable
def initialize
@items = {}
@results_cache = {}

View File

@ -3,6 +3,10 @@ require File.expand_path("../../base", __FILE__)
describe Vagrant::Registry do
let(:instance) { described_class.new }
it "should include enumerable" do
expect(instance).to be_a(Enumerable)
end
it "should return nil for nonexistent items" do
expect(instance.get("foo")).to be_nil
end