diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-07-11 13:52:57 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-07-11 13:52:57 -0700 |
commit | c603f1b0dba5024485b9b6c53c16dab38d9029f1 (patch) | |
tree | 30ae803321154a1cf1280787f7a1c1ad94565d08 /lib/chef/decorator | |
parent | dfe3498c68da48362b6bf8d558ecd3386702cd45 (diff) | |
download | chef-c603f1b0dba5024485b9b6c53c16dab38d9029f1.tar.gz |
add back method_missing support to set_unless
closes #5012
Diffstat (limited to 'lib/chef/decorator')
-rw-r--r-- | lib/chef/decorator/unchain.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/chef/decorator/unchain.rb b/lib/chef/decorator/unchain.rb index 30179d4e63..7d6adcb095 100644 --- a/lib/chef/decorator/unchain.rb +++ b/lib/chef/decorator/unchain.rb @@ -38,6 +38,22 @@ class Chef __path__.push(key) @delegate_sd_obj.public_send(__method__, *__path__, value) end + + # unfortunately we have to support method_missing for node.set_unless.foo.bar = 'baz' notation + def method_missing(symbol, *args) + if symbol == :to_ary + merged_attributes.send(symbol, *args) + elsif args.empty? + Chef.log_deprecation %q{"method access to node attributes (node.foo.bar) is deprecated and will be removed in Chef 13, please use bracket syntax (node["foo"]["bar"])} + self[symbol] + elsif symbol.to_s =~ /=$/ + Chef.log_deprecation %q{"method setting of node attributes (node.foo="bar") is deprecated and will be removed in Chef 13, please use bracket syntax (node["foo"]="bar")} + key_to_set = symbol.to_s[/^(.+)=$/, 1] + self[key_to_set] = (args.length == 1 ? args[0] : args) + else + raise NoMethodError, "Undefined node attribute or method `#{symbol}' on `node'" + end + end end end end |