- From: Charles Duffy <
>
- To: chef-users <
>
- Subject: [chef] Chef::Node::Attribute trying to call Hash methods on Array types
- Date: Wed, 29 Dec 2010 18:58:27 -0600
Howdy!
I'm trying to determine whether the following behavior constitutes a bug:
chef > node.default[:foo] = []
=> []
chef > node.set[:foo] << {:foo => "bar"}
=> {:foo=>"bar"}
chef > node[:foo].each { |entry| puts entry[:foo] }
NoMethodError: undefined method `keys' for []:Array
from /usr/lib64/ruby/gems/1.8/gems/chef-0.9.12/lib/chef/node/attribute.rb:250:in `keys'
from /usr/lib64/ruby/gems/1.8/gems/chef-0.9.12/lib/chef/node/attribute.rb:248:in `each'
from /usr/lib64/ruby/gems/1.8/gems/chef-0.9.12/lib/chef/node/attribute.rb:248:in `keys'
from /usr/lib64/ruby/gems/1.8/gems/chef-0.9.12/lib/chef/node/attribute.rb:243:in `get_keys'
from /usr/lib64/ruby/gems/1.8/gems/chef-0.9.12/lib/chef/node/attribute.rb:129:in `each'
from (irb):22
from :0
This happens because Chef::Node::Attribute's each instance calls get_keys, which in turn calls keys, which isn't available for an array.
Is there an idiom I should be using which would avoid this issue?
- [chef] Chef::Node::Attribute trying to call Hash methods on Array types, Charles Duffy, 12/29/2010
Archive powered by MHonArc 2.6.16.