diff options
author | Serdar Sutay <serdar@opscode.com> | 2014-10-22 12:39:09 -0700 |
---|---|---|
committer | Serdar Sutay <serdar@opscode.com> | 2014-10-22 12:39:09 -0700 |
commit | 937db2df6a7a44b9a4c1a9f7a65508b15e1115a1 (patch) | |
tree | 96b0c94d920eeafd4b9a263c53f2ee9141bef528 /lib | |
parent | ed164c6386c89c5fbe2918ebda06028332724034 (diff) | |
parent | 099b907a763cd9e531903f858eee0940c16248e2 (diff) | |
download | chef-937db2df6a7a44b9a4c1a9f7a65508b15e1115a1.tar.gz |
Merge pull request #2265 from opscode/sersut/resource-list-specs
Add missing specs for List
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/resource_collection/resource_list.rb | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/lib/chef/resource_collection/resource_list.rb b/lib/chef/resource_collection/resource_list.rb index e083cc0a9f..a26bd347aa 100644 --- a/lib/chef/resource_collection/resource_list.rb +++ b/lib/chef/resource_collection/resource_list.rb @@ -19,6 +19,7 @@ require 'chef/resource' require 'chef/resource_collection/stepable_iterator' require 'chef/resource_collection/resource_collection_serialization' +require 'forwardable' # This class keeps the list of all known Resources in the order they are to be executed in. It also keeps a pointer # to the most recently executed resource so we can add resources-to-execute after this point. @@ -27,9 +28,17 @@ class Chef class ResourceList include ResourceCollection::ResourceCollectionSerialization include Enumerable + extend Forwardable attr_reader :iterator + attr_reader :resources + private :resources + # Delegate direct access methods to the @resources array + # 4 extra methods here are not included in the Enumerable's instance methods + direct_access_methods = Enumerable.instance_methods + [ :[], :each, :each_index, :empty? ] + def_delegators :resources, *(direct_access_methods) + def initialize @resources = Array.new @insert_after_idx = nil @@ -67,16 +76,6 @@ class Chef @resources end - def [](index) - @resources[index] - end - - def each - @resources.each do |resource| - yield resource - end - end - def execute_each_resource(&resource_exec_block) @iterator = ResourceCollection::StepableIterator.for_collection(@resources) @iterator.each_with_index do |resource, idx| @@ -85,17 +84,6 @@ class Chef end end - def each_index - @resources.each_index do |i| - yield i - end - end - - def empty? - @resources.empty? - end - end end end - |