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
|
# This allows certain components (such as guest systems, configuration
|
||||||
# pieces, etc.) to be registered and queried, lazily.
|
# pieces, etc.) to be registered and queried, lazily.
|
||||||
class Registry
|
class Registry
|
||||||
|
include Enumerable
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@items = {}
|
@items = {}
|
||||||
@results_cache = {}
|
@results_cache = {}
|
||||||
|
|
|
@ -3,6 +3,10 @@ require File.expand_path("../../base", __FILE__)
|
||||||
describe Vagrant::Registry do
|
describe Vagrant::Registry do
|
||||||
let(:instance) { described_class.new }
|
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
|
it "should return nil for nonexistent items" do
|
||||||
expect(instance.get("foo")).to be_nil
|
expect(instance.get("foo")).to be_nil
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue