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:
parent
bc4bbb9fc0
commit
2b03838fba
|
@ -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 = {}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue