summaryrefslogtreecommitdiff
path: root/lib/chef/resource_collection.rb
diff options
context:
space:
mode:
authortyler-ball <tyleraball@gmail.com>2014-10-17 10:21:57 -0500
committertyler-ball <tyleraball@gmail.com>2014-10-17 10:21:57 -0500
commit335072475b38df2550dc78ad3f4a340dfc908ece (patch)
tree711606a84f5eea08c950fd6d027e1bc12a225809 /lib/chef/resource_collection.rb
parent9323a77206955327fef2f17a42ca5e66c864cb26 (diff)
downloadchef-335072475b38df2550dc78ad3f4a340dfc908ece.tar.gz
Fixing ruby 1.9.3 build errorstball/bsd_package_name
Diffstat (limited to 'lib/chef/resource_collection.rb')
-rw-r--r--lib/chef/resource_collection.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/chef/resource_collection.rb b/lib/chef/resource_collection.rb
index 8a02651d7d..772be0b68d 100644
--- a/lib/chef/resource_collection.rb
+++ b/lib/chef/resource_collection.rb
@@ -44,7 +44,10 @@ class Chef
# If you know the at_location but not the resource_type or instance_name, pass them in as nil
# This method is meant to be the 1 insert method necessary in the future. It should support all known use cases
# for writing into the ResourceCollection.
- def insert(resource, resource_type:nil, instance_name:nil, at_location:nil)
+ def insert(resource, opts={})
+ resource_type ||= opts[:resource_type] # Would rather use Ruby 2.x syntax, but oh well
+ instance_name ||= opts[:instance_name]
+ at_location ||= opts[:at_location]
if at_location
@resource_list.insert_at(at_location, resource)
else
@@ -89,13 +92,13 @@ class Chef
# Read-only methods are simple to delegate - doing that below
- RESOURCE_LIST_METHODS = Enumerable.instance_methods +
+ resource_list_methods = Enumerable.instance_methods +
[:iterator, :all_resources, :[], :each, :execute_each_resource, :each_index, :empty?] -
[:find] # find needs to run on the set
- RESOURCE_SET_METHODS = [:lookup, :find, :resources, :keys, :validate_lookup_spec!]
+ resource_set_methods = [:lookup, :find, :resources, :keys, :validate_lookup_spec!]
- def_delegators :@resource_list, *RESOURCE_LIST_METHODS
- def_delegators :@resource_set, *RESOURCE_SET_METHODS
+ def_delegators :@resource_list, *resource_list_methods
+ def_delegators :@resource_set, *resource_set_methods
end
end