diff options
author | Tim Smith <tsmith@chef.io> | 2021-03-24 19:46:26 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-24 19:46:26 -0700 |
commit | 87452da7a5b501ba95d50c126cc9a7a2966352b8 (patch) | |
tree | 33aea304ef5a2108b02a93721ec46c114cea5da5 | |
parent | f9fbeaf7a3224f00d45d19bdb2801dddcb61dccf (diff) | |
parent | 358d9625aac8d8044ca233490bbadb1f21d174ac (diff) | |
download | chef-87452da7a5b501ba95d50c126cc9a7a2966352b8.tar.gz |
Merge pull request #11234 from chef/lcg/databag-item-delegation
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/chef/data_bag_item.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/chef/data_bag_item.rb b/lib/chef/data_bag_item.rb index 94cf2a5317..3a4adb84cc 100644 --- a/lib/chef/data_bag_item.rb +++ b/lib/chef/data_bag_item.rb @@ -44,8 +44,17 @@ class Chef end end - # Define all Hash's instance methods as delegating to @raw_data - def_delegators(:@raw_data, *(Hash.instance_methods - Object.instance_methods)) + # delegate missing methods to the @raw_data Hash + def method_missing(method_name, *arguments, &block) + @raw_data.send(method_name, *arguments, &block) + rescue + # throw more sensible errors back at the user + super + end + + def respond_to_missing?(method_name, include_private = false) + @raw_data.respond_to?(method_name, include_private) || super + end attr_reader :raw_data |